From 1621d0d58fc9cad0a33b88603cf06f2c2271d921 Mon Sep 17 00:00:00 2001 From: lusoris Date: Thu, 26 Nov 2026 13:08:49 +0100 Subject: [PATCH] test(registry): pin full outputs in the registry function net Round three of the registry function net compares the whole output of each target function with an expected value the test builds from code, instead of checking single fields. Two new files cover the channel and identity gates and the command line, with a fixture for each branch, and `make test` runs all three function net files. An AST mutant sweep over 29 functions made 2,401 mutants; with 85 review and earlier-round mutants that is 2,486. A replay of the whole net per mutant kills 2,037. 37 are equivalent, each with a written argument, and 412 sweep mutants survive. The pull request lists the survivors by function, and an issue tracks them. Signed-off-by: lusoris --- Makefile | 2 +- .../tests/test_registry_function_net.py | 2248 +++++++++-------- .../test_registry_function_net_channels.py | 1451 +++++++++++ .../tests/test_registry_function_net_cli.py | 1483 +++++++++++ 4 files changed, 4071 insertions(+), 1113 deletions(-) create mode 100644 tools/knowledge-registry/tests/test_registry_function_net_channels.py create mode 100644 tools/knowledge-registry/tests/test_registry_function_net_cli.py diff --git a/Makefile b/Makefile index b91a5fd..5cf8b49 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ test: build @cd tools/knowledge-snapshot && go test -p 4 -v -count=1 ./... @cd tools/knowledge-retrieval && go test -p 4 -v -count=1 -run 'Test(BM25|Dense|Current|Hybrid|Lifecycle|Paired|Situating|FineSpan|SharedCanonicalJSONConformance)' ./... @python3 -m pytest -q tools/knowledge-dogfood-evidence/tests/test_fail_closed.py tools/knowledge-dogfood-evidence/tests/test_regex_backtracking.py - @python3 -m pytest -q tools/knowledge-registry/tests/test_subprocess_deadlines.py tools/knowledge-registry/tests/test_registry_function_net.py + @python3 -m pytest -q tools/knowledge-registry/tests/test_subprocess_deadlines.py tools/knowledge-registry/tests/test_registry_function_net.py tools/knowledge-registry/tests/test_registry_function_net_channels.py tools/knowledge-registry/tests/test_registry_function_net_cli.py @python3 -m pytest -q apps/ai/kb-mcp/files/test_mcpo_proxy.py @python3 tools/knowledge-registry/tests/test_canonical_json_conformance.py @helm lint apps/ai/kb-mcp diff --git a/tools/knowledge-registry/tests/test_registry_function_net.py b/tools/knowledge-registry/tests/test_registry_function_net.py index 747d48b..d3247db 100644 --- a/tools/knowledge-registry/tests/test_registry_function_net.py +++ b/tools/knowledge-registry/tests/test_registry_function_net.py @@ -3,23 +3,59 @@ from __future__ import annotations +import ast import hashlib -import io -import json -import re +import importlib.util +import shutil import sys import tempfile import unittest -from collections.abc import Mapping -from contextlib import redirect_stderr, redirect_stdout +from collections.abc import Callable, Mapping +from dataclasses import asdict +from importlib.machinery import SourceFileLoader from pathlib import Path +from types import CodeType, ModuleType from typing import Any -from unittest.mock import Mock, patch +from unittest.mock import patch TOOL_ROOT = Path(__file__).resolve().parents[1] -with patch.object(sys, "path", [str(TOOL_ROOT), *sys.path]): - import capture_live as live - import knowledge_registry as kr + + +class RegistrySourceLoader(SourceFileLoader): + """Load the exact named source without reading or creating bytecode files.""" + + def get_code(self, fullname: str) -> CodeType: + """Compile the source file named by the bound module spec.""" + path = self.get_filename(fullname) + return self.source_to_code(self.get_data(path), path) + + +def load_module( + tool_root: Path, stem: str, aliases: dict[str, ModuleType] +) -> ModuleType: + """Execute one test module with temporary import bindings.""" + path = tool_root / f"{stem}.py" + key = hashlib.sha256(str(tool_root).encode()).hexdigest() + name = f"_registry_function_net_{key}_{stem}" + loader = RegistrySourceLoader(name, str(path)) + spec = importlib.util.spec_from_file_location(name, path, loader=loader) + if spec is None or spec.loader is None: + raise ImportError(path) + module = importlib.util.module_from_spec(spec) + with patch.dict(sys.modules, {name: module, **aliases}): + spec.loader.exec_module(module) + return module + + +def load_tool_modules(tool_root: Path) -> tuple[ModuleType, ModuleType]: + """Load the registry and its capture helper from the same resolved root.""" + root = tool_root.resolve() + registry = load_module(root, "knowledge_registry", {}) + capture = load_module(root, "capture_live", {"knowledge_registry": registry}) + return registry, capture + + +kr, live = load_tool_modules(TOOL_ROOT) Record = dict[str, Any] MAX_FIXTURE_ROWS = 4 @@ -39,18 +75,6 @@ def only(records: Mapping[str, Record]) -> Record: return record -def gap_types(builder: kr.Builder) -> set[str]: - """Collect the explicitly emitted gap types.""" - return {gap["gap_type"] for gap in fixture_rows(builder.extra_gaps)} - - -def fixture_rows(records: Mapping[str, Record]) -> tuple[Record, ...]: - """Bound the builder tables inspected by fixture assertions.""" - if len(records) > MAX_FIXTURE_ROWS: - raise AssertionError(f"builder table exceeds {MAX_FIXTURE_ROWS} fixture rows") - return tuple(records.values()) - - def source_builder() -> tuple[kr.Builder, str]: """Create a builder with one neutral source.""" builder = kr.Builder() @@ -65,6 +89,522 @@ def local_builder() -> tuple[kr.Builder, str, str, str]: return builder, source_id, component, version +BIND_ARGUMENT_COUNT = 3 +MAX_OUTPUT_TABLES = 8 +OUTPUT_TABLES = ( + "sources", + "components", + "versions", + "occurrences", + "edges", + "extra_gaps", + "discovery_inputs", + "node_platforms", +) + + +def observation_state(builder: kr.Builder) -> Record: + """Keep the keys, full records, and insertion order of every builder table.""" + return { + table: list(getattr(builder, table).items()) + for table in OUTPUT_TABLES[:MAX_OUTPUT_TABLES] + } + + +def assert_output( + case: unittest.TestCase, expected: str, value: Any, args: tuple[Any, ...] +) -> None: + """Compare the complete return value and each caller-owned output collection.""" + if args and isinstance(args[0], kr.Builder): + value = (value, observation_state(args[0])) + elif args and isinstance(args[0], list) and len(args) == BIND_ARGUMENT_COUNT: + value = (value, args[0]) + root = getattr(case, "root", None) + if root is not None and "/__fixture_root__" in expected: + escaped_root = ( + str(root).replace("\\", "\\\\").replace("'", "\\x27").replace('"', "\\x22") + ) + expected = expected.replace("/__fixture_root__", escaped_root) + case.assertEqual(value, ast.literal_eval(expected)) + + +def check_output( + case: unittest.TestCase, + expected: dict[str, str], + label: str, + call: Callable[..., Any], + *args: Any, + **kwargs: Any, +) -> Any: + """Check the function result, complete error, and caller-owned state.""" + try: + value = call(*args, **kwargs) + except kr.RegistryInputError as exc: + assert_output(case, expected[label], (type(exc).__name__, str(exc)), args) + raise + assert_output(case, expected[label], value, args) + return value + + +EXPECTED: dict[str, str] = { + "test_add_workflow_manifest_install.1": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-96798a62afd2f5a456064757', {'component_id': 'cmp-96798a62afd2f5a456064757', 'ecosystem': 'local', 'kind': 'fixture', 'lifecycles': ['repository-used'], 'name': 'input.json', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), ('cmp-f97173ccf16a0fa3fe954c60', {'component_id': 'cmp-f97173ccf16a0fa3fe954c60', 'ecosystem': 'npm', 'kind': 'node-project', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-b5e5f51f6ef2c47aceaed9ef', {'component_id': 'cmp-96798a62afd2f5a456064757', 'component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'evidence': ['input.json'], 'resolution_state': 'resolved', 'source_ref': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}), + ('ver-98289a24cf73e05fb9bddcbe', {'component_id': 'cmp-f97173ccf16a0fa3fe954c60', 'component_version_id': 'ver-98289a24cf73e05fb9bddcbe', 'evidence': ['app/package.json'], 'resolution_state': 'resolved', 'resolved_version': '1.2.3', 'source_ref': 'sha256:055f36abac1de416965362266ef0524f9a464b3c06f628cf546587d51779cf8c'})], + 'occurrences': [('occ-bda9a82b749007b4fbd88203', {'component_id': 'cmp-f97173ccf16a0fa3fe954c60', 'component_version_id': 'ver-98289a24cf73e05fb9bddcbe', 'dependency_scope': 'ci', 'directness': 'direct', 'evidence_locator': '/steps/0', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-bda9a82b749007b4fbd88203', 'optional': False, 'raw_value': 'npm install:app/package.json', 'role': 'github-actions-manifest-install', 'root_id': 'cmp-96798a62afd2f5a456064757', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-7afeb484016f94c632a3ac8f', {'edge_id': 'edge-7afeb484016f94c632a3ac8f', 'from_component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'optional': False, 'relationship': 'installs-manifest', 'resolver': 'github-actions', 'scope': 'ci', 'source_occurrence_id': 'occ-bda9a82b749007b4fbd88203', 'to_component_version_id': 'ver-98289a24cf73e05fb9bddcbe'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_add_workflow_manifest_install.2": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-96798a62afd2f5a456064757', {'component_id': 'cmp-96798a62afd2f5a456064757', 'ecosystem': 'local', 'kind': 'fixture', 'lifecycles': ['repository-used'], 'name': 'input.json', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), ('cmp-f97173ccf16a0fa3fe954c60', {'component_id': 'cmp-f97173ccf16a0fa3fe954c60', 'ecosystem': 'npm', 'kind': 'node-project', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-b5e5f51f6ef2c47aceaed9ef', {'component_id': 'cmp-96798a62afd2f5a456064757', 'component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'evidence': ['input.json'], 'resolution_state': 'resolved', 'source_ref': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}), + ('ver-98289a24cf73e05fb9bddcbe', {'component_id': 'cmp-f97173ccf16a0fa3fe954c60', 'component_version_id': 'ver-98289a24cf73e05fb9bddcbe', 'evidence': ['app/package.json'], 'resolution_state': 'resolved', 'resolved_version': '1.2.3', 'source_ref': 'sha256:055f36abac1de416965362266ef0524f9a464b3c06f628cf546587d51779cf8c'})], + 'occurrences': [('occ-bda9a82b749007b4fbd88203', {'component_id': 'cmp-f97173ccf16a0fa3fe954c60', 'component_version_id': 'ver-98289a24cf73e05fb9bddcbe', 'dependency_scope': 'ci', 'directness': 'direct', 'evidence_locator': '/steps/0', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-bda9a82b749007b4fbd88203', 'optional': False, 'raw_value': 'npm install:app/package.json', 'role': 'github-actions-manifest-install', 'root_id': 'cmp-96798a62afd2f5a456064757', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-7afeb484016f94c632a3ac8f', {'edge_id': 'edge-7afeb484016f94c632a3ac8f', 'from_component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'optional': False, 'relationship': 'installs-manifest', 'resolver': 'github-actions', 'scope': 'ci', 'source_occurrence_id': 'occ-bda9a82b749007b4fbd88203', 'to_component_version_id': 'ver-98289a24cf73e05fb9bddcbe'})], + 'extra_gaps': [('gap-80e80dc73696bd53b17326b4', {'evidence': ['input.json#/steps/1'], 'gap_id': 'gap-80e80dc73696bd53b17326b4', 'gap_type': 'github-actions-install-manifest-unresolved', 'message': 'npm install at /steps/1 has no readable package.json in ignored', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_scan_chart_lock.1": r"""(None, + {'sources': [('src-035e3dcf3af885cdc940aaa6', {'content_hash': 'sha256:5d6b46ec9a4ede324b28f8732dd446bb861cce2789e6690bc196f4e282b3389d', 'evidence_uri': 'Chart.lock', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-035e3dcf3af885cdc940aaa6', 'source_type': 'helm-chart-lock'}), + ('src-b836decc2466786191594c81', {'content_hash': 'sha256:8884eaf2869865cc8e8c9597073c498222381f5db083b58b498fa3577393d81e', 'evidence_uri': 'Chart.yaml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-b836decc2466786191594c81', 'source_type': 'helm-chart-metadata'})], + 'components': [('cmp-10e5b92b9c672353486d6b0d', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-a253a30045bfbe31e7bec233', {'component_id': 'cmp-a253a30045bfbe31e7bec233', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['repository-used'], 'metadata': {'chart_repository': 'https://charts.example.org'}, 'name': 'child', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-fa505e79446445b2bce533b0', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'component_version_id': 'ver-fa505e79446445b2bce533b0', 'evidence': ['Chart.yaml'], 'resolution_state': 'resolved', 'resolved_version': '2.0.0', 'source_ref': 'sha256:8884eaf2869865cc8e8c9597073c498222381f5db083b58b498fa3577393d81e'}), ('ver-974bf8da8def146365baba11', {'component_id': 'cmp-a253a30045bfbe31e7bec233', 'component_version_id': 'ver-974bf8da8def146365baba11', 'evidence': ['Chart.lock#L2'], 'resolution_state': 'resolved', 'resolved_version': '1.2.3'})], + 'occurrences': [('occ-ede445a90460c95cb1a8de8b', {'component_id': 'cmp-a253a30045bfbe31e7bec233', 'component_version_id': 'ver-974bf8da8def146365baba11', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': 'line:2:lock:0', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-ede445a90460c95cb1a8de8b', 'optional': False, 'raw_value': 'child@1.2.3', 'role': 'helm-locked-dependency', 'root_id': 'cmp-10e5b92b9c672353486d6b0d', 'source_id': 'src-035e3dcf3af885cdc940aaa6'})], + 'edges': [('edge-2f00007d5167c671caefaeac', {'constraint': '1.2.3', 'edge_id': 'edge-2f00007d5167c671caefaeac', 'from_component_version_id': 'ver-fa505e79446445b2bce533b0', 'optional': False, 'relationship': 'locks', 'resolver': 'helm-lock', 'scope': 'runtime', 'source_occurrence_id': 'occ-ede445a90460c95cb1a8de8b', 'to_component_version_id': 'ver-974bf8da8def146365baba11'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_scan_chart_lock.2": r"""(None, + {'sources': [('src-035e3dcf3af885cdc940aaa6', {'content_hash': 'sha256:5d6b46ec9a4ede324b28f8732dd446bb861cce2789e6690bc196f4e282b3389d', 'evidence_uri': 'Chart.lock', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-035e3dcf3af885cdc940aaa6', 'source_type': 'helm-chart-lock'}), + ('src-04b35e20b1ec627715465363', {'content_hash': 'sha256:67b3fc5c5f146761fe76135436d14ae3869aee6c935cff85dd8ef465c16d3078', 'evidence_uri': 'Chart.yaml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-04b35e20b1ec627715465363', 'source_type': 'helm-chart-metadata'})], + 'components': [('cmp-10e5b92b9c672353486d6b0d', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-a253a30045bfbe31e7bec233', {'component_id': 'cmp-a253a30045bfbe31e7bec233', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['repository-used'], 'metadata': {'chart_repository': 'https://charts.example.org'}, 'name': 'child', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-08e1970c0bb179bb7ffe6317', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'component_version_id': 'ver-08e1970c0bb179bb7ffe6317', 'evidence': ['Chart.yaml'], 'resolution_state': 'resolved', 'resolved_version': '2.0.0', 'source_ref': 'sha256:67b3fc5c5f146761fe76135436d14ae3869aee6c935cff85dd8ef465c16d3078'}), ('ver-974bf8da8def146365baba11', {'component_id': 'cmp-a253a30045bfbe31e7bec233', 'component_version_id': 'ver-974bf8da8def146365baba11', 'evidence': ['Chart.lock#L2'], 'resolution_state': 'resolved', 'resolved_version': '1.2.3'})], + 'occurrences': [('occ-ede445a90460c95cb1a8de8b', {'component_id': 'cmp-a253a30045bfbe31e7bec233', 'component_version_id': 'ver-974bf8da8def146365baba11', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': 'line:2:lock:0', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-ede445a90460c95cb1a8de8b', 'optional': False, 'raw_value': 'child@1.2.3', 'role': 'helm-locked-dependency', 'root_id': 'cmp-10e5b92b9c672353486d6b0d', 'source_id': 'src-035e3dcf3af885cdc940aaa6'})], + 'edges': [('edge-a5de9566f050f8374c659bf2', {'constraint': '^1.2.0', 'edge_id': 'edge-a5de9566f050f8374c659bf2', 'from_component_version_id': 'ver-08e1970c0bb179bb7ffe6317', 'optional': False, 'relationship': 'locks', 'resolver': 'helm-lock', 'scope': 'runtime', 'source_occurrence_id': 'occ-ede445a90460c95cb1a8de8b', 'to_component_version_id': 'ver-974bf8da8def146365baba11'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_scan_chart_lock.3": r"""(None, + {'sources': [('src-22c3c9734cdd15e6a2998833', {'content_hash': 'sha256:4d840406bc73f4a8458f54af84744318ffa8470e76a50921351481d4563e24a9', 'evidence_uri': 'Chart.lock', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-22c3c9734cdd15e6a2998833', 'source_type': 'helm-chart-lock'}), + ('src-b836decc2466786191594c81', {'content_hash': 'sha256:8884eaf2869865cc8e8c9597073c498222381f5db083b58b498fa3577393d81e', 'evidence_uri': 'Chart.yaml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-b836decc2466786191594c81', 'source_type': 'helm-chart-metadata'})], + 'components': [('cmp-10e5b92b9c672353486d6b0d', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-a253a30045bfbe31e7bec233', {'component_id': 'cmp-a253a30045bfbe31e7bec233', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['repository-used'], 'metadata': {'chart_repository': 'https://charts.example.org'}, 'name': 'child', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-fa505e79446445b2bce533b0', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'component_version_id': 'ver-fa505e79446445b2bce533b0', 'evidence': ['Chart.yaml'], 'resolution_state': 'resolved', 'resolved_version': '2.0.0', 'source_ref': 'sha256:8884eaf2869865cc8e8c9597073c498222381f5db083b58b498fa3577393d81e'}), ('ver-21334cc14822eec2921d4d2e', {'component_id': 'cmp-a253a30045bfbe31e7bec233', 'component_version_id': 'ver-21334cc14822eec2921d4d2e', 'evidence': ['Chart.lock#L2'], 'resolution_state': 'resolved', 'resolved_version': '1.2.4'})], + 'occurrences': [('occ-d8ccf5004f11125ef24debdb', {'component_id': 'cmp-a253a30045bfbe31e7bec233', 'component_version_id': 'ver-21334cc14822eec2921d4d2e', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': 'line:2:lock:0', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-d8ccf5004f11125ef24debdb', 'optional': False, 'raw_value': 'child@1.2.4', 'role': 'helm-locked-dependency', 'root_id': 'cmp-10e5b92b9c672353486d6b0d', 'source_id': 'src-22c3c9734cdd15e6a2998833'})], + 'edges': [('edge-76bffba006ac5f0d2a2fa388', {'constraint': '1.2.3', 'edge_id': 'edge-76bffba006ac5f0d2a2fa388', 'from_component_version_id': 'ver-fa505e79446445b2bce533b0', 'optional': False, 'relationship': 'locks', 'resolver': 'helm-lock', 'scope': 'runtime', 'source_occurrence_id': 'occ-d8ccf5004f11125ef24debdb', 'to_component_version_id': 'ver-21334cc14822eec2921d4d2e'})], + 'extra_gaps': [('gap-988b0da28eb47128b7e5e6f5', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'component_version_id': 'ver-fa505e79446445b2bce533b0', 'evidence': ['Chart.lock#L2'], 'gap_id': 'gap-988b0da28eb47128b7e5e6f5', 'gap_type': 'helm-lock-version-mismatch', 'message': "Chart.lock locks 'child' at '1.2.4', but Chart.yaml declares '1.2.3'", 'source_id': 'src-22c3c9734cdd15e6a2998833'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_scan_chart_lock.4": r"""(None, + {'sources': [('src-f734a572e8640ef89ea076bc', {'content_hash': 'sha256:0df94ce5ec4b5512129e8547022f265ca59d05d1a16999f307bcd69b8f1b44c0', 'evidence_uri': 'Chart.lock', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-f734a572e8640ef89ea076bc', 'source_type': 'helm-chart-lock'}), + ('src-b836decc2466786191594c81', {'content_hash': 'sha256:8884eaf2869865cc8e8c9597073c498222381f5db083b58b498fa3577393d81e', 'evidence_uri': 'Chart.yaml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-b836decc2466786191594c81', 'source_type': 'helm-chart-metadata'})], + 'components': [('cmp-10e5b92b9c672353486d6b0d', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-693e4f424eec09cf695e7d4e', {'component_id': 'cmp-693e4f424eec09cf695e7d4e', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['repository-used'], 'metadata': {'chart_repository': 'https://charts.example.net'}, 'name': 'child', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-fa505e79446445b2bce533b0', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'component_version_id': 'ver-fa505e79446445b2bce533b0', 'evidence': ['Chart.yaml'], 'resolution_state': 'resolved', 'resolved_version': '2.0.0', 'source_ref': 'sha256:8884eaf2869865cc8e8c9597073c498222381f5db083b58b498fa3577393d81e'}), ('ver-bed8ffbd0134b0f27014b1d8', {'component_id': 'cmp-693e4f424eec09cf695e7d4e', 'component_version_id': 'ver-bed8ffbd0134b0f27014b1d8', 'evidence': ['Chart.lock#L2'], 'resolution_state': 'resolved', 'resolved_version': '1.2.3'})], + 'occurrences': [('occ-cf795f86722bc2df0cdfb980', {'component_id': 'cmp-693e4f424eec09cf695e7d4e', 'component_version_id': 'ver-bed8ffbd0134b0f27014b1d8', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': 'line:2:lock:0', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-cf795f86722bc2df0cdfb980', 'optional': False, 'raw_value': 'child@1.2.3', 'role': 'helm-locked-dependency', 'root_id': 'cmp-10e5b92b9c672353486d6b0d', 'source_id': 'src-f734a572e8640ef89ea076bc'})], + 'edges': [('edge-82d2fca36945d9838dad39e2', {'constraint': '1.2.3', 'edge_id': 'edge-82d2fca36945d9838dad39e2', 'from_component_version_id': 'ver-fa505e79446445b2bce533b0', 'optional': False, 'relationship': 'locks', 'resolver': 'helm-lock', 'scope': 'runtime', 'source_occurrence_id': 'occ-cf795f86722bc2df0cdfb980', 'to_component_version_id': 'ver-bed8ffbd0134b0f27014b1d8'})], + 'extra_gaps': [('gap-2cc58fa55f1ff050369f22a7', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'component_version_id': 'ver-fa505e79446445b2bce533b0', 'evidence': ['Chart.lock#L2', 'Chart.yaml#L4'], 'gap_id': 'gap-2cc58fa55f1ff050369f22a7', 'gap_type': 'helm-lock-repository-mismatch', 'message': "Chart.lock locks 'child' from 'https://charts.example.net', declared as 'https://charts.example.org'", 'source_id': 'src-f734a572e8640ef89ea076bc'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_scan_codex_config.1": r"""(None, + {'sources': [('src-44d5eb656d3b809441976981', {'content_hash': 'sha256:f38f255712959f2515e551e14c2795773a52817139cad07a91e197769e173a1b', 'evidence_uri': 'config.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-44d5eb656d3b809441976981', 'source_type': 'codex-config'})], + 'components': [('cmp-0e2047679351ff658356304a', {'component_id': 'cmp-0e2047679351ff658356304a', 'ecosystem': 'local', 'kind': 'codex-config', 'lifecycles': ['repository-used'], 'name': 'config.toml', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-b7dcdede2070f224392f4504', {'component_id': 'cmp-b7dcdede2070f224392f4504', 'ecosystem': 'mcp', 'kind': 'mcp-server-endpoint', 'lifecycles': ['repository-used'], 'metadata': {'endpoint': 'https://example.org/mcp'}, 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-a438b92c28eaf6733559ac7c', {'component_id': 'cmp-a438b92c28eaf6733559ac7c', 'ecosystem': 'mcp', 'kind': 'mcp-server-endpoint', 'lifecycles': ['repository-used'], 'metadata': {'endpoint': 'https://example.net/mcp'}, 'name': 'default', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-0bb09fc328b53f15fe2f2641', {'component_id': 'cmp-0e2047679351ff658356304a', 'component_version_id': 'ver-0bb09fc328b53f15fe2f2641', 'evidence': ['config.toml'], 'resolution_state': 'resolved', 'source_ref': 'sha256:f38f255712959f2515e551e14c2795773a52817139cad07a91e197769e173a1b'}), + ('ver-e2ec6d2a35b494be99aaac53', {'component_id': 'cmp-b7dcdede2070f224392f4504', 'component_version_id': 'ver-e2ec6d2a35b494be99aaac53', 'evidence': ['config.toml#L1'], 'resolution_state': 'resolved', 'source_ref': 'sha256:f38f255712959f2515e551e14c2795773a52817139cad07a91e197769e173a1b'}), + ('ver-ffd54fc02dfe4fe7940ccf28', {'component_id': 'cmp-a438b92c28eaf6733559ac7c', 'component_version_id': 'ver-ffd54fc02dfe4fe7940ccf28', 'evidence': ['config.toml#L6'], 'resolution_state': 'resolved', 'source_ref': 'sha256:f38f255712959f2515e551e14c2795773a52817139cad07a91e197769e173a1b'})], + 'occurrences': [('occ-138a5a109d7423aaa3357bc8', + {'component_id': 'cmp-b7dcdede2070f224392f4504', 'component_version_id': 'ver-e2ec6d2a35b494be99aaac53', 'dependency_scope': 'development', 'directness': 'direct', 'evidence_locator': 'line:1', 'lifecycle': 'repository-used', 'metadata': {'enabled': False, 'required': True, 'enabled_tools': ['read', 'write']}, 'occurrence_id': 'occ-138a5a109d7423aaa3357bc8', 'optional': False, 'raw_value': 'https://example.org/mcp', 'role': 'mcp-server-endpoint', 'root_id': 'cmp-0e2047679351ff658356304a', 'source_id': 'src-44d5eb656d3b809441976981'}), + ('occ-db4b052518d305c8e2c29d09', {'component_id': 'cmp-a438b92c28eaf6733559ac7c', 'component_version_id': 'ver-ffd54fc02dfe4fe7940ccf28', 'dependency_scope': 'development', 'directness': 'direct', 'evidence_locator': 'line:6', 'lifecycle': 'repository-used', 'metadata': {'enabled': True, 'required': False, 'enabled_tools': []}, 'occurrence_id': 'occ-db4b052518d305c8e2c29d09', 'optional': False, 'raw_value': 'https://example.net/mcp', 'role': 'mcp-server-endpoint', 'root_id': 'cmp-0e2047679351ff658356304a', 'source_id': 'src-44d5eb656d3b809441976981'})], + 'edges': [('edge-e2509f18211580300bfcdf40', {'edge_id': 'edge-e2509f18211580300bfcdf40', 'from_component_version_id': 'ver-0bb09fc328b53f15fe2f2641', 'metadata': {'enabled': False, 'required': True, 'enabled_tools': ['read', 'write']}, 'optional': False, 'relationship': 'configures', 'resolver': 'codex-config', 'scope': 'development', 'source_occurrence_id': 'occ-138a5a109d7423aaa3357bc8', 'to_component_version_id': 'ver-e2ec6d2a35b494be99aaac53'}), + ('edge-7d1585911c31df8f2511746d', {'edge_id': 'edge-7d1585911c31df8f2511746d', 'from_component_version_id': 'ver-0bb09fc328b53f15fe2f2641', 'metadata': {'enabled': True, 'required': False, 'enabled_tools': []}, 'optional': False, 'relationship': 'configures', 'resolver': 'codex-config', 'scope': 'development', 'source_occurrence_id': 'occ-db4b052518d305c8e2c29d09', 'to_component_version_id': 'ver-ffd54fc02dfe4fe7940ccf28'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_scan_codex_config.2": r"""(None, + {'sources': [('src-d0cb320485a81e8eac03f72a', {'content_hash': 'sha256:245843abef9e72e7efac30138a994bf6301e7e1d7d7042a33d42e863d2638811', 'evidence_uri': 'config.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-d0cb320485a81e8eac03f72a', 'source_type': 'codex-config'})], + 'components': [], + 'versions': [], + 'occurrences': [], + 'edges': [], + 'extra_gaps': [('gap-cdb6374cc219d4a1b9c92303', {'evidence': ['/__fixture_root__/config.toml'], 'gap_id': 'gap-cdb6374cc219d4a1b9c92303', 'gap_type': 'toml-invalid', 'message': 'Invalid initial character for a key part (at end of document)', 'source_id': 'src-d0cb320485a81e8eac03f72a'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_scan_containerd_hosts.1": r"""(None, + {'sources': [('src-c6f32ee1d7580679c61395df', {'content_hash': 'sha256:fa06d50f5722c1460029bb3fcc517ffe75498986a42837ab350a6b9159fe84ff', 'evidence_uri': 'hosts.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-c6f32ee1d7580679c61395df', 'source_type': 'containerd-hosts'})], + 'components': [('cmp-bf447d20dea721e92f1f0db9', {'component_id': 'cmp-bf447d20dea721e92f1f0db9', 'ecosystem': 'local', 'kind': 'containerd-hosts', 'lifecycles': ['repository-used'], 'name': 'hosts.toml', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-46b2866a7f560d01e5a21285', {'component_id': 'cmp-46b2866a7f560d01e5a21285', 'ecosystem': 'oci-registry', 'kind': 'registry-endpoint', 'lifecycles': ['repository-used'], 'metadata': {'endpoint': 'https://registry.example.org'}, 'name': 'https://registry.example.org', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-1ceabc92035cd5e96035d3c2', {'component_id': 'cmp-1ceabc92035cd5e96035d3c2', 'ecosystem': 'oci-registry', 'kind': 'registry-endpoint', 'lifecycles': ['repository-used'], 'metadata': {'endpoint': 'https://mirror.example.org'}, 'name': 'https://mirror.example.org', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-83c9aa570551f951e003dec4', {'component_id': 'cmp-bf447d20dea721e92f1f0db9', 'component_version_id': 'ver-83c9aa570551f951e003dec4', 'evidence': ['hosts.toml'], 'resolution_state': 'resolved', 'source_ref': 'sha256:fa06d50f5722c1460029bb3fcc517ffe75498986a42837ab350a6b9159fe84ff'}), + ('ver-f7a42635f12dc1ca86b539f5', {'component_id': 'cmp-46b2866a7f560d01e5a21285', 'component_version_id': 'ver-f7a42635f12dc1ca86b539f5', 'evidence': ['hosts.toml#L1'], 'resolution_state': 'resolved', 'source_ref': 'sha256:fa06d50f5722c1460029bb3fcc517ffe75498986a42837ab350a6b9159fe84ff'}), + ('ver-941df3cee76f41ac79967191', {'component_id': 'cmp-1ceabc92035cd5e96035d3c2', 'component_version_id': 'ver-941df3cee76f41ac79967191', 'evidence': ['hosts.toml#L2'], 'resolution_state': 'resolved', 'source_ref': 'sha256:fa06d50f5722c1460029bb3fcc517ffe75498986a42837ab350a6b9159fe84ff'})], + 'occurrences': [('occ-97cfb10f2b093fe01e83921d', {'component_id': 'cmp-46b2866a7f560d01e5a21285', 'component_version_id': 'ver-f7a42635f12dc1ca86b539f5', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': 'line:1', 'lifecycle': 'repository-used', 'metadata': {'registry_server': True}, 'occurrence_id': 'occ-97cfb10f2b093fe01e83921d', 'optional': False, 'raw_value': 'https://registry.example.org', 'role': 'containerd-registry-server', 'root_id': 'cmp-bf447d20dea721e92f1f0db9', 'source_id': 'src-c6f32ee1d7580679c61395df'}), + ('occ-e3df28b1adda40faac902b49', + {'component_id': 'cmp-1ceabc92035cd5e96035d3c2', 'component_version_id': 'ver-941df3cee76f41ac79967191', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': 'line:2', 'lifecycle': 'repository-used', 'metadata': {'capabilities': ['pull'], 'override_path': True, 'skip_verify': False}, 'occurrence_id': 'occ-e3df28b1adda40faac902b49', 'optional': False, 'raw_value': 'https://mirror.example.org', 'role': 'containerd-registry-mirror', 'root_id': 'cmp-bf447d20dea721e92f1f0db9', 'source_id': 'src-c6f32ee1d7580679c61395df'})], + 'edges': [('edge-3b365d053d55d83ba766d4b4', {'edge_id': 'edge-3b365d053d55d83ba766d4b4', 'from_component_version_id': 'ver-83c9aa570551f951e003dec4', 'metadata': {'registry_server': True}, 'optional': False, 'relationship': 'configures', 'resolver': 'containerd-hosts', 'scope': 'deployment', 'source_occurrence_id': 'occ-97cfb10f2b093fe01e83921d', 'to_component_version_id': 'ver-f7a42635f12dc1ca86b539f5'}), + ('edge-7a7bdf2adcad8f66316e1192', {'edge_id': 'edge-7a7bdf2adcad8f66316e1192', 'from_component_version_id': 'ver-83c9aa570551f951e003dec4', 'metadata': {'capabilities': ['pull'], 'override_path': True, 'skip_verify': False}, 'optional': False, 'relationship': 'routes-through', 'resolver': 'containerd-hosts', 'scope': 'deployment', 'source_occurrence_id': 'occ-e3df28b1adda40faac902b49', 'to_component_version_id': 'ver-941df3cee76f41ac79967191'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_scan_containerd_hosts.2": r"""(None, + {'sources': [('src-ea9f055e935931a82d293c50', {'content_hash': 'sha256:5842c97e862ef11691b4bd3aebf57eb42aff22d9d6e2386fb7d8ce9cea37ee75', 'evidence_uri': 'hosts.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-ea9f055e935931a82d293c50', 'source_type': 'containerd-hosts'})], + 'components': [], + 'versions': [], + 'occurrences': [], + 'edges': [], + 'extra_gaps': [('gap-25751460c118371e37907db2', {'evidence': ['/__fixture_root__/hosts.toml'], 'gap_id': 'gap-25751460c118371e37907db2', 'gap_type': 'toml-invalid', 'message': 'Invalid value (at end of document)', 'source_id': 'src-ea9f055e935931a82d293c50'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_scan_pyproject.1": r"""(None, + {'sources': [('src-aaa24686549db347ae21281c', {'content_hash': 'sha256:80ef73d9ed5fba18153aca5dc32e09c4cfc0a568489650576fdd297128dbe375', 'evidence_uri': 'pyproject.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-aaa24686549db347ae21281c', 'source_type': 'python-pyproject'})], + 'components': [('cmp-d9338ccdf165a0f8be71aa02', {'component_id': 'cmp-d9338ccdf165a0f8be71aa02', 'ecosystem': 'pypi', 'kind': 'python-project', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': [], 'purl': 'pkg:pypi/app'}), + ('cmp-16057b6621f6bbc3107663e7', {'component_id': 'cmp-16057b6621f6bbc3107663e7', 'ecosystem': 'python-toolchain', 'kind': 'language-toolchain', 'lifecycles': ['repository-used'], 'metadata': {'language': 'python'}, 'name': 'python', 'namespace': '', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:generic/python-toolchain'}), + ('cmp-3b610d576cae0def35a7cb37', {'component_id': 'cmp-3b610d576cae0def35a7cb37', 'ecosystem': 'python-toolchain', 'kind': 'standard-library', 'lifecycles': ['repository-used'], 'metadata': {'language': 'python', 'coupled_to_toolchain': True}, 'name': 'python-stdlib', 'namespace': '', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:generic/python-stdlib'}), + ('cmp-257fc68c98b4e395108581b2', {'component_id': 'cmp-257fc68c98b4e395108581b2', 'ecosystem': 'pypi', 'kind': 'library', 'lifecycles': ['repository-used'], 'name': 'example-dep', 'namespace': '', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:pypi/example-dep'})], + 'versions': [('ver-ce4b555ae08ed56184ed246a', {'component_id': 'cmp-d9338ccdf165a0f8be71aa02', 'component_version_id': 'ver-ce4b555ae08ed56184ed246a', 'evidence': ['pyproject.toml'], 'resolution_state': 'resolved', 'resolved_version': '1.2.3', 'source_ref': 'sha256:80ef73d9ed5fba18153aca5dc32e09c4cfc0a568489650576fdd297128dbe375'}), + ('ver-9bf3c76ea001be386641821c', {'component_id': 'cmp-16057b6621f6bbc3107663e7', 'component_version_id': 'ver-9bf3c76ea001be386641821c', 'constraint': '>=3.11', 'evidence': ['pyproject.toml#line:6'], 'metadata': {'raw_toolchain_version': '>=3.11'}, 'resolution_state': 'partial'}), ('ver-729bda291bf45690811ec47f', {'component_id': 'cmp-3b610d576cae0def35a7cb37', 'component_version_id': 'ver-729bda291bf45690811ec47f', 'constraint': '>=3.11', 'evidence': ['pyproject.toml#line:6'], 'metadata': {'raw_toolchain_version': '>=3.11'}, 'resolution_state': 'partial'}), + ('ver-795f58aea434ef6b37e4df99', {'component_id': 'cmp-257fc68c98b4e395108581b2', 'component_version_id': 'ver-795f58aea434ef6b37e4df99', 'constraint': '==2.3.4', 'evidence': ['pyproject.toml#line:5:column:17'], 'resolution_state': 'resolved', 'resolved_version': '2.3.4'})], + 'occurrences': [('occ-f84b4dd84779b3905c3290a6', {'component_id': 'cmp-16057b6621f6bbc3107663e7', 'component_version_id': 'ver-9bf3c76ea001be386641821c', 'dependency_scope': 'build', 'directness': 'direct', 'evidence_locator': 'line:6', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-f84b4dd84779b3905c3290a6', 'optional': False, 'raw_value': '>=3.11', 'role': 'python-requires-version', 'root_id': 'cmp-d9338ccdf165a0f8be71aa02', 'source_id': 'src-aaa24686549db347ae21281c'}), + ('occ-e4c55a731f4158a8a07c4e61', {'component_id': 'cmp-3b610d576cae0def35a7cb37', 'component_version_id': 'ver-729bda291bf45690811ec47f', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': 'line:6:stdlib', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-e4c55a731f4158a8a07c4e61', 'optional': False, 'raw_value': '>=3.11', 'role': 'python-standard-library', 'root_id': 'cmp-16057b6621f6bbc3107663e7', 'source_id': 'src-aaa24686549db347ae21281c'}), + ('occ-67180144d2c1f0681576d58a', {'component_id': 'cmp-257fc68c98b4e395108581b2', 'component_version_id': 'ver-795f58aea434ef6b37e4df99', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': 'line:5:column:17', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-67180144d2c1f0681576d58a', 'optional': True, 'raw_value': 'Example_Dep==2.3.4', 'role': 'pyproject-dependency', 'root_id': 'cmp-d9338ccdf165a0f8be71aa02', 'source_id': 'src-aaa24686549db347ae21281c'})], + 'edges': [('edge-acf0a5a2fbbd972301dea296', {'constraint': '>=3.11', 'edge_id': 'edge-acf0a5a2fbbd972301dea296', 'from_component_version_id': 'ver-ce4b555ae08ed56184ed246a', 'optional': False, 'relationship': 'requires-toolchain', 'resolver': 'toolchain-observation', 'scope': 'build', 'source_occurrence_id': 'occ-f84b4dd84779b3905c3290a6', 'to_component_version_id': 'ver-9bf3c76ea001be386641821c'}), + ('edge-fcb4d95ca898676cf5e0f25d', {'constraint': '>=3.11', 'edge_id': 'edge-fcb4d95ca898676cf5e0f25d', 'from_component_version_id': 'ver-9bf3c76ea001be386641821c', 'optional': False, 'relationship': 'provides-standard-library', 'resolver': 'toolchain-observation', 'scope': 'runtime', 'source_occurrence_id': 'occ-e4c55a731f4158a8a07c4e61', 'to_component_version_id': 'ver-729bda291bf45690811ec47f'}), + ('edge-127c08811dc00f053a9a73fa', {'constraint': '==2.3.4', 'edge_id': 'edge-127c08811dc00f053a9a73fa', 'from_component_version_id': 'ver-ce4b555ae08ed56184ed246a', 'optional': True, 'relationship': 'depends-on', 'resolver': 'python-manifest', 'scope': 'runtime', 'source_occurrence_id': 'occ-67180144d2c1f0681576d58a', 'to_component_version_id': 'ver-795f58aea434ef6b37e4df99'})], + 'extra_gaps': [('gap-3e692835043537cc37322962', {'component_id': 'cmp-16057b6621f6bbc3107663e7', 'component_version_id': 'ver-9bf3c76ea001be386641821c', 'evidence': ['pyproject.toml#line:6'], 'gap_id': 'gap-3e692835043537cc37322962', 'gap_type': 'toolchain-exact-version-unresolved', 'message': "python toolchain constraint '>=3.11' lacks an exact runtime version", 'metadata': {'language': 'python', 'surface': 'toolchain'}, 'source_id': 'src-aaa24686549db347ae21281c'}), + ('gap-1cc6ceadf8a5f1956ef82f22', {'component_id': 'cmp-3b610d576cae0def35a7cb37', 'component_version_id': 'ver-729bda291bf45690811ec47f', 'evidence': ['pyproject.toml#line:6'], 'gap_id': 'gap-1cc6ceadf8a5f1956ef82f22', 'gap_type': 'toolchain-exact-version-unresolved', 'message': "python standard library constraint '>=3.11' lacks an exact runtime version", 'metadata': {'language': 'python', 'surface': 'standard library'}, 'source_id': 'src-aaa24686549db347ae21281c'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_scan_script_dependencies.1": r"""(None, + {'sources': [('src-039fe82820b9cd97109e4c21', {'content_hash': 'sha256:c9a717d10b2584f2348086ff72a6652096f37afce764801c33c62440370bf5ef', 'evidence_uri': 'app.py', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-039fe82820b9cd97109e4c21', 'source_type': 'script-dependencies'})], + 'components': [('cmp-573ec625b75de401a754c4db', {'component_id': 'cmp-573ec625b75de401a754c4db', 'ecosystem': 'local', 'kind': 'automation-script', 'lifecycles': ['repository-used'], 'name': 'app.py', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), ('cmp-d80183028eb6e50b2f53021e', {'component_id': 'cmp-d80183028eb6e50b2f53021e', 'ecosystem': 'pypi', 'kind': 'library', 'lifecycles': ['repository-used'], 'name': 'pyyaml', 'namespace': '', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:pypi/pyyaml'}), + ('cmp-2b67f332d5fc6fb28d8bd9c4', {'component_id': 'cmp-2b67f332d5fc6fb28d8bd9c4', 'ecosystem': 'pypi', 'kind': 'library', 'lifecycles': ['repository-used'], 'name': 'jsonschema', 'namespace': '', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:pypi/jsonschema'}), + ('cmp-f9dffcd8a9c72f6b0e786db7', {'component_id': 'cmp-f9dffcd8a9c72f6b0e786db7', 'ecosystem': 'pypi', 'kind': 'library', 'lifecycles': ['repository-used'], 'name': 'optimum', 'namespace': '', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:pypi/optimum'})], + 'versions': [('ver-c96da01036b38cc571a238d1', {'component_id': 'cmp-573ec625b75de401a754c4db', 'component_version_id': 'ver-c96da01036b38cc571a238d1', 'evidence': ['app.py'], 'resolution_state': 'resolved', 'source_ref': 'sha256:c9a717d10b2584f2348086ff72a6652096f37afce764801c33c62440370bf5ef'}), ('ver-fb600f6d874284f295f4da89', {'component_id': 'cmp-d80183028eb6e50b2f53021e', 'component_version_id': 'ver-fb600f6d874284f295f4da89', 'evidence': ['app.py#L1', 'app.py#line:1', 'requirements.txt#L1'], 'resolution_state': 'resolved', 'resolved_version': '1.2.3'}), + ('ver-5f26612414163eb7be772fd0', {'component_id': 'cmp-2b67f332d5fc6fb28d8bd9c4', 'component_version_id': 'ver-5f26612414163eb7be772fd0', 'constraint': 'unversioned', 'evidence': ['app.py#line:3'], 'resolution_state': 'unresolved'}), ('ver-9c19406f2c21e15453feccd8', {'component_id': 'cmp-f9dffcd8a9c72f6b0e786db7', 'component_version_id': 'ver-9c19406f2c21e15453feccd8', 'evidence': ['app.py#L4', 'app.py#line:4', 'requirements.txt#L2'], 'resolution_state': 'resolved', 'resolved_version': '2.3.4'})], + 'occurrences': [('occ-5facf4223e401a10c98675a5', {'component_id': 'cmp-d80183028eb6e50b2f53021e', 'component_version_id': 'ver-fb600f6d874284f295f4da89', 'dependency_scope': 'automation', 'directness': 'direct', 'evidence_locator': 'line:1', 'lifecycle': 'repository-used', 'metadata': {'distribution': 'PyYAML'}, 'occurrence_id': 'occ-5facf4223e401a10c98675a5', 'optional': False, 'raw_value': 'PyYAML==1.2.3', 'role': 'script-direct-dependency', 'root_id': 'cmp-573ec625b75de401a754c4db', 'source_id': 'src-039fe82820b9cd97109e4c21'}), + ('occ-9c4c665ee7a2c047de73b2d3', {'component_id': 'cmp-2b67f332d5fc6fb28d8bd9c4', 'component_version_id': 'ver-5f26612414163eb7be772fd0', 'dependency_scope': 'automation', 'directness': 'direct', 'evidence_locator': 'line:3', 'lifecycle': 'conditional', 'metadata': {'distribution': 'jsonschema'}, 'occurrence_id': 'occ-9c4c665ee7a2c047de73b2d3', 'optional': True, 'raw_value': 'jsonschema', 'role': 'script-direct-dependency', 'root_id': 'cmp-573ec625b75de401a754c4db', 'source_id': 'src-039fe82820b9cd97109e4c21'}), + ('occ-fd9ef95546f167cdff21c70f', {'component_id': 'cmp-f9dffcd8a9c72f6b0e786db7', 'component_version_id': 'ver-9c19406f2c21e15453feccd8', 'dependency_scope': 'automation', 'directness': 'direct', 'evidence_locator': 'line:4', 'lifecycle': 'repository-used', 'metadata': {'distribution': 'optimum'}, 'occurrence_id': 'occ-fd9ef95546f167cdff21c70f', 'optional': False, 'raw_value': 'optimum==2.3.4', 'role': 'script-direct-dependency', 'root_id': 'cmp-573ec625b75de401a754c4db', 'source_id': 'src-039fe82820b9cd97109e4c21'})], + 'edges': [('edge-a350255d3facd7a5808bf9ac', {'constraint': '1.2.3', 'edge_id': 'edge-a350255d3facd7a5808bf9ac', 'from_component_version_id': 'ver-c96da01036b38cc571a238d1', 'metadata': {'distribution': 'PyYAML'}, 'optional': False, 'relationship': 'depends-on', 'resolver': 'sibling-python-requirements', 'scope': 'automation', 'source_occurrence_id': 'occ-5facf4223e401a10c98675a5', 'to_component_version_id': 'ver-fb600f6d874284f295f4da89'}), + ('edge-623b43f0b58bd74baf92acd2', {'constraint': 'unversioned', 'edge_id': 'edge-623b43f0b58bd74baf92acd2', 'from_component_version_id': 'ver-c96da01036b38cc571a238d1', 'metadata': {'distribution': 'jsonschema'}, 'optional': True, 'relationship': 'depends-on', 'resolver': 'sibling-python-requirements', 'scope': 'automation', 'source_occurrence_id': 'occ-9c4c665ee7a2c047de73b2d3', 'to_component_version_id': 'ver-5f26612414163eb7be772fd0'}), + ('edge-30e52f244ce1eaadadc196cf', {'constraint': '2.3.4', 'edge_id': 'edge-30e52f244ce1eaadadc196cf', 'from_component_version_id': 'ver-c96da01036b38cc571a238d1', 'metadata': {'distribution': 'optimum'}, 'optional': False, 'relationship': 'depends-on', 'resolver': 'sibling-python-requirements', 'scope': 'automation', 'source_occurrence_id': 'occ-fd9ef95546f167cdff21c70f', 'to_component_version_id': 'ver-9c19406f2c21e15453feccd8'})], + 'extra_gaps': [('gap-fa32665673cf1bf5670e9469', {'component_id': 'cmp-2b67f332d5fc6fb28d8bd9c4', 'component_version_id': 'ver-5f26612414163eb7be772fd0', 'evidence': ['app.py#L3'], 'gap_id': 'gap-fa32665673cf1bf5670e9469', 'gap_type': 'script-dependency-pin-missing', 'message': "app.py directly uses 'jsonschema' without a sibling requirement pin", 'source_id': 'src-039fe82820b9cd97109e4c21'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_add_model_artifact_observation.1": r"""(('cmp-c29cb040a3285ba7e6ab95f8', 'ver-c682df2d3e0cddf406b3e9e3', 'occ-f7fb378dcce9f53863d39559'), + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-96798a62afd2f5a456064757', {'component_id': 'cmp-96798a62afd2f5a456064757', 'ecosystem': 'local', 'kind': 'fixture', 'lifecycles': ['repository-used'], 'name': 'input.json', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-c29cb040a3285ba7e6ab95f8', {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'ecosystem': 'huggingface', 'kind': 'model-artifact', 'lifecycles': ['repository-used'], 'metadata': {'artifact_identity': 'example/app', 'lineage_required': True, 'lineage_evidence': ['input.json#/model']}, 'name': 'app', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-b5e5f51f6ef2c47aceaed9ef', {'component_id': 'cmp-96798a62afd2f5a456064757', 'component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'evidence': ['input.json'], 'resolution_state': 'resolved', 'source_ref': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}), + ('ver-c682df2d3e0cddf406b3e9e3', {'artifact_digest': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-c682df2d3e0cddf406b3e9e3', 'evidence': ['input.json#/model'], 'metadata': {'artifact_identity': 'example/app', 'lineage_required': True, 'lineage_evidence': ['input.json#/model']}, 'resolution_state': 'resolved', 'resolved_version': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', 'source_ref': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'})], + 'occurrences': [('occ-f7fb378dcce9f53863d39559', + {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-c682df2d3e0cddf406b3e9e3', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/model', 'lifecycle': 'repository-used', 'metadata': {'artifact_identity': 'example/app', 'lineage_required': True, 'lineage_evidence': ['input.json#/model']}, 'occurrence_id': 'occ-f7fb378dcce9f53863d39559', 'optional': False, 'raw_value': 'example/app', 'role': 'fixture-model', 'root_id': 'cmp-96798a62afd2f5a456064757', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-b699180541f493e7c42925f7', {'edge_id': 'edge-b699180541f493e7c42925f7', 'from_component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'optional': False, 'relationship': 'uses-model-artifact', 'resolver': 'model-artifact-discovery', 'scope': 'runtime', 'source_occurrence_id': 'occ-f7fb378dcce9f53863d39559', 'to_component_version_id': 'ver-c682df2d3e0cddf406b3e9e3'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_add_model_artifact_observation.2": r"""(('cmp-c29cb040a3285ba7e6ab95f8', 'ver-157817821115105f98e0a27c', 'occ-5459e825fcd718eeccf78e52'), + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-96798a62afd2f5a456064757', {'component_id': 'cmp-96798a62afd2f5a456064757', 'ecosystem': 'local', 'kind': 'fixture', 'lifecycles': ['repository-used'], 'name': 'input.json', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-c29cb040a3285ba7e6ab95f8', {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'ecosystem': 'huggingface', 'kind': 'model-artifact', 'lifecycles': ['repository-used'], 'metadata': {'artifact_identity': 'example/app', 'lineage_required': True, 'lineage_evidence': ['input.json#/model']}, 'name': 'app', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-b5e5f51f6ef2c47aceaed9ef', {'component_id': 'cmp-96798a62afd2f5a456064757', 'component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'evidence': ['input.json'], 'resolution_state': 'resolved', 'source_ref': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}), + ('ver-c682df2d3e0cddf406b3e9e3', {'artifact_digest': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-c682df2d3e0cddf406b3e9e3', 'evidence': ['input.json#/model'], 'metadata': {'artifact_identity': 'example/app', 'lineage_required': True, 'lineage_evidence': ['input.json#/model']}, 'resolution_state': 'resolved', 'resolved_version': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', 'source_ref': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'}), + ('ver-157817821115105f98e0a27c', {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-157817821115105f98e0a27c', 'constraint': 'immutable-revision-or-hash-required', 'evidence': ['input.json#/model'], 'metadata': {'artifact_identity': 'example/app'}, 'resolution_state': 'unresolved', 'source_ref': 'main'})], + 'occurrences': [('occ-f7fb378dcce9f53863d39559', + {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-c682df2d3e0cddf406b3e9e3', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/model', 'lifecycle': 'repository-used', 'metadata': {'artifact_identity': 'example/app', 'lineage_required': True, 'lineage_evidence': ['input.json#/model']}, 'occurrence_id': 'occ-f7fb378dcce9f53863d39559', 'optional': False, 'raw_value': 'example/app', 'role': 'fixture-model', 'root_id': 'cmp-96798a62afd2f5a456064757', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-5459e825fcd718eeccf78e52', {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-157817821115105f98e0a27c', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/model', 'lifecycle': 'repository-used', 'metadata': {'artifact_identity': 'example/app'}, 'occurrence_id': 'occ-5459e825fcd718eeccf78e52', 'optional': False, 'raw_value': 'example/app', 'role': 'fixture-model', 'root_id': 'cmp-96798a62afd2f5a456064757', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-b699180541f493e7c42925f7', {'edge_id': 'edge-b699180541f493e7c42925f7', 'from_component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'optional': False, 'relationship': 'uses-model-artifact', 'resolver': 'model-artifact-discovery', 'scope': 'runtime', 'source_occurrence_id': 'occ-f7fb378dcce9f53863d39559', 'to_component_version_id': 'ver-c682df2d3e0cddf406b3e9e3'}), + ('edge-50e9197852b5834781246365', {'edge_id': 'edge-50e9197852b5834781246365', 'from_component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'optional': False, 'relationship': 'uses-model-artifact', 'resolver': 'model-artifact-discovery', 'scope': 'runtime', 'source_occurrence_id': 'occ-5459e825fcd718eeccf78e52', 'to_component_version_id': 'ver-157817821115105f98e0a27c'})], + 'extra_gaps': [('gap-d35924e733f6a3decd08e01c', {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-157817821115105f98e0a27c', 'evidence': ['input.json#/model'], 'gap_id': 'gap-d35924e733f6a3decd08e01c', 'gap_type': 'model-artifact-integrity-unresolved', 'message': "Model artifact 'example/app' has no immutable content hash", 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('gap-1f4e783ff6af748c71066815', {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-157817821115105f98e0a27c', 'evidence': ['input.json#/model'], 'gap_id': 'gap-1f4e783ff6af748c71066815', 'gap_type': 'model-artifact-revision-unresolved', 'message': "Hugging Face model 'example/app' has no immutable revision", 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_add_model_artifact_observation_resolves_revision_without_digest.1": r"""(('cmp-c29cb040a3285ba7e6ab95f8', 'ver-5cee9f5b2c7237f5871223f6', 'occ-93c5a8c9b53834d3b7477f30'), + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-96798a62afd2f5a456064757', {'component_id': 'cmp-96798a62afd2f5a456064757', 'ecosystem': 'local', 'kind': 'fixture', 'lifecycles': ['repository-used'], 'name': 'input.json', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-c29cb040a3285ba7e6ab95f8', {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'ecosystem': 'huggingface', 'kind': 'model-artifact', 'lifecycles': ['repository-used'], 'metadata': {'artifact_identity': 'example/app'}, 'name': 'app', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-b5e5f51f6ef2c47aceaed9ef', {'component_id': 'cmp-96798a62afd2f5a456064757', 'component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'evidence': ['input.json'], 'resolution_state': 'resolved', 'source_ref': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}), + ('ver-5cee9f5b2c7237f5871223f6', {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-5cee9f5b2c7237f5871223f6', 'evidence': ['input.json#/model'], 'metadata': {'artifact_identity': 'example/app'}, 'resolution_state': 'resolved', 'resolved_version': '1.2.3', 'source_ref': '1.2.3'})], + 'occurrences': [('occ-93c5a8c9b53834d3b7477f30', {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-5cee9f5b2c7237f5871223f6', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/model', 'lifecycle': 'repository-used', 'metadata': {'artifact_identity': 'example/app'}, 'occurrence_id': 'occ-93c5a8c9b53834d3b7477f30', 'optional': False, 'raw_value': 'example/app', 'role': 'fixture-model', 'root_id': 'cmp-96798a62afd2f5a456064757', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-c61f681334ef203f4502ea5a', {'edge_id': 'edge-c61f681334ef203f4502ea5a', 'from_component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'optional': False, 'relationship': 'uses-model-artifact', 'resolver': 'model-artifact-discovery', 'scope': 'runtime', 'source_occurrence_id': 'occ-93c5a8c9b53834d3b7477f30', 'to_component_version_id': 'ver-5cee9f5b2c7237f5871223f6'})], + 'extra_gaps': [('gap-9a9ce7b487530c5ab119ad62', {'component_id': 'cmp-c29cb040a3285ba7e6ab95f8', 'component_version_id': 'ver-5cee9f5b2c7237f5871223f6', 'evidence': ['input.json#/model'], 'gap_id': 'gap-9a9ce7b487530c5ab119ad62', 'gap_type': 'model-artifact-integrity-unresolved', 'message': "Model artifact 'example/app' has no immutable content hash", 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "argo-empty": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-1d4bb1461c07ff4730edbaf5', {'component_id': 'cmp-1d4bb1461c07ff4730edbaf5', 'ecosystem': 'argocd', 'kind': 'argo-applicationset', 'lifecycles': ['deployed'], 'name': 'app', 'namespace': 'example', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-9d9d126b0ef5b6bf449e5b4b', {'component_id': 'cmp-1d4bb1461c07ff4730edbaf5', 'component_version_id': 'ver-9d9d126b0ef5b6bf449e5b4b', 'constraint': 'live-observation', 'evidence': ['input.json#/items/0'], 'metadata': {'sync_status': None, 'health_status': None, 'reconciled_at': None, 'revisions': [], 'operation_phase': None, 'operation_started_at': None, 'operation_finished_at': None}, 'resolution_state': 'unresolved'})], + 'occurrences': [('occ-a8b80af27bdca9b01cdeeb59', {'component_id': 'cmp-1d4bb1461c07ff4730edbaf5', 'component_version_id': 'ver-9d9d126b0ef5b6bf449e5b4b', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/items/0', 'lifecycle': 'deployed', 'metadata': {'uid': None, 'resource_version': None}, 'occurrence_id': 'occ-a8b80af27bdca9b01cdeeb59', 'optional': False, 'raw_value': 'example/app', 'role': 'live-argo-application', 'root_id': 'cmp-1d4bb1461c07ff4730edbaf5', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "argo-git-target": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-3d5c1cbd9f2912e953741e57', {'component_id': 'cmp-3d5c1cbd9f2912e953741e57', 'ecosystem': 'argocd', 'kind': 'argo-application', 'lifecycles': ['deployed'], 'name': 'app', 'namespace': 'argocd', 'official_channel_required': False, 'official_channels': []}), + ('cmp-692b82b6e8949d9b4716581e', {'component_id': 'cmp-692b82b6e8949d9b4716581e', 'ecosystem': 'git', 'kind': 'git-repository', 'lifecycles': ['deployed'], 'metadata': {'source_repo': 'https://git.example.org/example/app.git', 'path': ''}, 'name': 'app', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-cb71ace23283960ece6af136', {'component_id': 'cmp-3d5c1cbd9f2912e953741e57', 'component_version_id': 'ver-cb71ace23283960ece6af136', 'constraint': 'live-observation', 'evidence': ['input.json#/items/0'], 'metadata': {'sync_status': None, 'health_status': None, 'reconciled_at': None, 'revisions': [], 'operation_phase': None, 'operation_started_at': None, 'operation_finished_at': None}, 'resolution_state': 'unresolved'}), + ('ver-f3d67f1d9bc58663fcd64ed8', {'component_id': 'cmp-692b82b6e8949d9b4716581e', 'component_version_id': 'ver-f3d67f1d9bc58663fcd64ed8', 'constraint': 'main', 'evidence': ['input.json#/items/0/spec/sources/1'], 'metadata': {'observed_revision': None}, 'resolution_state': 'unresolved', 'source_ref': 'main'})], + 'occurrences': [('occ-1bf0de38c846e9f337ca6ac1', {'component_id': 'cmp-3d5c1cbd9f2912e953741e57', 'component_version_id': 'ver-cb71ace23283960ece6af136', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/items/0', 'lifecycle': 'deployed', 'metadata': {'uid': None, 'resource_version': None}, 'occurrence_id': 'occ-1bf0de38c846e9f337ca6ac1', 'optional': False, 'raw_value': 'argocd/app', 'role': 'live-argo-application', 'root_id': 'cmp-3d5c1cbd9f2912e953741e57', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-412c2ee55ea921996764671b', {'component_id': 'cmp-692b82b6e8949d9b4716581e', 'component_version_id': 'ver-f3d67f1d9bc58663fcd64ed8', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': '/items/0/spec/sources/1', 'lifecycle': 'deployed', 'occurrence_id': 'occ-412c2ee55ea921996764671b', 'optional': False, 'raw_value': 'https://git.example.org/example/app.git#@main', 'role': 'live-argo-git-source', 'root_id': 'cmp-3d5c1cbd9f2912e953741e57', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-c6cfc98fdec101c3bbf648af', {'constraint': 'main', 'edge_id': 'edge-c6cfc98fdec101c3bbf648af', 'from_component_version_id': 'ver-cb71ace23283960ece6af136', 'metadata': {'observed_revision': None}, 'optional': False, 'relationship': 'desired-source', 'resolver': 'live-argocd', 'scope': 'deployment', 'source_occurrence_id': 'occ-412c2ee55ea921996764671b', 'to_component_version_id': 'ver-f3d67f1d9bc58663fcd64ed8'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "argo-observed-sources": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-3c51f46bb03bc673794dc2c2', {'component_id': 'cmp-3c51f46bb03bc673794dc2c2', 'ecosystem': 'argocd', 'kind': 'argo-application', 'lifecycles': ['deployed'], 'name': 'app', 'namespace': 'example', 'official_channel_required': False, 'official_channels': []}), ('cmp-02192ba03104976a9815028b', {'component_id': 'cmp-02192ba03104976a9815028b', 'ecosystem': 'git', 'kind': 'git-repository', 'lifecycles': ['deployed'], 'metadata': {'source_repo': 'https://git.example.org/example/app.git', 'path': 'app'}, 'name': 'app', 'namespace': '', 'official_channel_required': True, 'official_channels': []}), + ('cmp-217b2449447cfbbacbd34ffd', {'component_id': 'cmp-217b2449447cfbbacbd34ffd', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['deployed'], 'metadata': {'chart_repository': 'https://charts.example.org'}, 'name': 'app', 'namespace': '', 'official_channel_required': True, 'official_channels': []}), + ('cmp-e3a2012f0f8df626445ba38f', {'component_id': 'cmp-e3a2012f0f8df626445ba38f', 'ecosystem': 'oci', 'kind': 'oci-image', 'lifecycles': ['runtime-resolved'], 'metadata': {'oci_repository': 'registry.example.org/example/app'}, 'name': 'app', 'namespace': 'registry.example.org/example', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:oci/app?repository_url=registry.example.org/example/app'}), + ('cmp-be42d174ff2a25c887290790', {'component_id': 'cmp-be42d174ff2a25c887290790', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-api', 'lifecycles': ['deployed'], 'metadata': {'api_group': 'apps', 'gvk': 'apps/v1/Deployment'}, 'name': 'Deployment', 'namespace': 'apps', 'official_channel_required': True, 'official_channels': []}), + ('cmp-cce4c95ee3054b756308f6ce', {'component_id': 'cmp-cce4c95ee3054b756308f6ce', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-api', 'lifecycles': ['deployed'], 'metadata': {'api_group': 'core', 'gvk': 'core/unknown/unknown'}, 'name': 'unknown', 'namespace': 'core', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-91a6e4b3011d7a0c561637e3', + {'component_id': 'cmp-3c51f46bb03bc673794dc2c2', 'component_version_id': 'ver-91a6e4b3011d7a0c561637e3', 'evidence': ['input.json#/items/1'], 'metadata': {'sync_status': 'Synced', 'health_status': 'Healthy', 'reconciled_at': '2026-01-02T03:04:05Z', 'revisions': ['bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', '2.0.1'], 'operation_phase': 'Succeeded', 'operation_started_at': '2026-01-02T03:04:05Z', 'operation_finished_at': '2026-01-02T03:04:06Z'}, 'resolution_state': 'resolved', 'source_ref': 'revisions-sha256:d24eab624d08e6306fea3ee1ec88a3b2694d02de535870803ade42652563a4e0'}), + ('ver-a907cc3e61b2919c31066743', {'component_id': 'cmp-02192ba03104976a9815028b', 'component_version_id': 'ver-a907cc3e61b2919c31066743', 'constraint': 'main', 'evidence': ['input.json#/items/1/spec/sources/0'], 'metadata': {'observed_revision': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'}, 'resolution_state': 'resolved', 'source_ref': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'}), + ('ver-c16d75d5d5cec46431d5b05e', {'component_id': 'cmp-217b2449447cfbbacbd34ffd', 'component_version_id': 'ver-c16d75d5d5cec46431d5b05e', 'constraint': '2.0.0', 'evidence': ['input.json#/items/1/spec/sources/1'], 'metadata': {'observed_revision': '2.0.1'}, 'resolution_state': 'resolved', 'resolved_version': '2.0.1'}), + ('ver-1c3c4d5499f1433309cbcaa4', {'artifact_digest': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'component_id': 'cmp-e3a2012f0f8df626445ba38f', 'component_version_id': 'ver-1c3c4d5499f1433309cbcaa4', 'evidence': ['input.json#/items/1/status/operationState/syncResult/images/0'], 'resolution_state': 'resolved'}), + ('ver-657f03f1131dc2456116084f', {'artifact_digest': 'sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', 'component_id': 'cmp-e3a2012f0f8df626445ba38f', 'component_version_id': 'ver-657f03f1131dc2456116084f', 'evidence': ['input.json#/items/1/status/summary/images/0'], 'resolution_state': 'resolved'}), ('ver-c35cf67618df849203244857', {'component_id': 'cmp-be42d174ff2a25c887290790', 'component_version_id': 'ver-c35cf67618df849203244857', 'evidence': ['input.json#/items/1/status/resources/1'], 'resolution_state': 'resolved', 'resolved_version': 'v1'}), + ('ver-6e2d82e4b9b56515b2125f93', {'component_id': 'cmp-cce4c95ee3054b756308f6ce', 'component_version_id': 'ver-6e2d82e4b9b56515b2125f93', 'evidence': ['input.json#/items/1/status/resources/2'], 'resolution_state': 'resolved', 'resolved_version': 'unknown'})], + 'occurrences': [('occ-4effded7600f749f770172c7', {'component_id': 'cmp-3c51f46bb03bc673794dc2c2', 'component_version_id': 'ver-91a6e4b3011d7a0c561637e3', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/items/1', 'lifecycle': 'deployed', 'metadata': {'uid': 'fixture-id', 'resource_version': '42'}, 'occurrence_id': 'occ-4effded7600f749f770172c7', 'optional': False, 'raw_value': 'example/app', 'role': 'live-argo-application', 'root_id': 'cmp-3c51f46bb03bc673794dc2c2', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-b4a50772d913d36479cc3a44', {'component_id': 'cmp-02192ba03104976a9815028b', 'component_version_id': 'ver-a907cc3e61b2919c31066743', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': '/items/1/spec/sources/0', 'lifecycle': 'deployed', 'occurrence_id': 'occ-b4a50772d913d36479cc3a44', 'optional': False, 'raw_value': 'https://git.example.org/example/app.git#app@main', 'role': 'live-argo-git-source', 'root_id': 'cmp-3c51f46bb03bc673794dc2c2', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-3b09c2baf9f6dccf3d729457', {'component_id': 'cmp-217b2449447cfbbacbd34ffd', 'component_version_id': 'ver-c16d75d5d5cec46431d5b05e', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': '/items/1/spec/sources/1', 'lifecycle': 'deployed', 'occurrence_id': 'occ-3b09c2baf9f6dccf3d729457', 'optional': False, 'raw_value': 'https://charts.example.org#app@2.0.0', 'role': 'live-argo-helm-source', 'root_id': 'cmp-3c51f46bb03bc673794dc2c2', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-17a7a711033cc194046c2a21', + {'component_id': 'cmp-e3a2012f0f8df626445ba38f', + 'component_version_id': 'ver-1c3c4d5499f1433309cbcaa4', + 'dependency_scope': 'runtime', + 'directness': 'direct', + 'evidence_locator': '/items/1/status/operationState/syncResult/images/0', + 'lifecycle': 'runtime-resolved', + 'metadata': {'application': 'app', 'namespace': 'example', 'status_path': '/items/1/status/operationState/syncResult/images'}, + 'occurrence_id': 'occ-17a7a711033cc194046c2a21', + 'optional': False, + 'raw_value': 'registry.example.org/example/app@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'role': 'live-argo-operation-image', + 'root_id': 'cmp-3c51f46bb03bc673794dc2c2', + 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-47fa63394aeb97fa2bd4838b', + {'component_id': 'cmp-e3a2012f0f8df626445ba38f', + 'component_version_id': 'ver-657f03f1131dc2456116084f', + 'dependency_scope': 'runtime', + 'directness': 'direct', + 'evidence_locator': '/items/1/status/summary/images/0', + 'lifecycle': 'runtime-resolved', + 'metadata': {'application': 'app', 'namespace': 'example', 'status_path': '/items/1/status/summary/images'}, + 'occurrence_id': 'occ-47fa63394aeb97fa2bd4838b', + 'optional': False, + 'raw_value': 'registry.example.org/example/app@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', + 'role': 'live-argo-observed-image', + 'root_id': 'cmp-3c51f46bb03bc673794dc2c2', + 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-30ac7a62a85ca601f85c13e8', {'component_id': 'cmp-be42d174ff2a25c887290790', 'component_version_id': 'ver-c35cf67618df849203244857', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/items/1/status/resources/1', 'lifecycle': 'deployed', 'metadata': {'namespace': 'example', 'name': 'app', 'status': 'Synced'}, 'occurrence_id': 'occ-30ac7a62a85ca601f85c13e8', 'optional': False, 'raw_value': 'apps/v1/Deployment', 'role': 'live-argo-managed-resource', 'root_id': 'cmp-3c51f46bb03bc673794dc2c2', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-6b26a4c39038a9cbb8d673aa', {'component_id': 'cmp-cce4c95ee3054b756308f6ce', 'component_version_id': 'ver-6e2d82e4b9b56515b2125f93', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/items/1/status/resources/2', 'lifecycle': 'deployed', 'occurrence_id': 'occ-6b26a4c39038a9cbb8d673aa', 'optional': False, 'raw_value': 'core/unknown/unknown', 'role': 'live-argo-managed-resource', 'root_id': 'cmp-3c51f46bb03bc673794dc2c2', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-9b15a861926f0d7c0783abb9', {'constraint': 'main', 'edge_id': 'edge-9b15a861926f0d7c0783abb9', 'from_component_version_id': 'ver-91a6e4b3011d7a0c561637e3', 'metadata': {'observed_revision': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'}, 'optional': False, 'relationship': 'desired-source', 'resolver': 'live-argocd', 'scope': 'deployment', 'source_occurrence_id': 'occ-b4a50772d913d36479cc3a44', 'to_component_version_id': 'ver-a907cc3e61b2919c31066743'}), + ('edge-4a8fb458c114b1405421a192', {'constraint': '2.0.0', 'edge_id': 'edge-4a8fb458c114b1405421a192', 'from_component_version_id': 'ver-91a6e4b3011d7a0c561637e3', 'metadata': {'observed_revision': '2.0.1'}, 'optional': False, 'relationship': 'desired-source', 'resolver': 'live-argocd', 'scope': 'deployment', 'source_occurrence_id': 'occ-3b09c2baf9f6dccf3d729457', 'to_component_version_id': 'ver-c16d75d5d5cec46431d5b05e'}), + ('edge-7ccbe6662eb647e6b1beb2f6', {'edge_id': 'edge-7ccbe6662eb647e6b1beb2f6', 'from_component_version_id': 'ver-91a6e4b3011d7a0c561637e3', 'optional': False, 'relationship': 'observes-image', 'resolver': 'live-argocd-status', 'scope': 'runtime', 'source_occurrence_id': 'occ-17a7a711033cc194046c2a21', 'to_component_version_id': 'ver-1c3c4d5499f1433309cbcaa4'}), + ('edge-469d4295244bf27382d7529f', {'edge_id': 'edge-469d4295244bf27382d7529f', 'from_component_version_id': 'ver-91a6e4b3011d7a0c561637e3', 'optional': False, 'relationship': 'observes-image', 'resolver': 'live-argocd-status', 'scope': 'runtime', 'source_occurrence_id': 'occ-47fa63394aeb97fa2bd4838b', 'to_component_version_id': 'ver-657f03f1131dc2456116084f'}), + ('edge-7ec9837d1d7d643491de9e8d', {'edge_id': 'edge-7ec9837d1d7d643491de9e8d', 'from_component_version_id': 'ver-91a6e4b3011d7a0c561637e3', 'optional': False, 'relationship': 'manages-api', 'resolver': 'live-argocd-status', 'scope': 'deployment', 'source_occurrence_id': 'occ-30ac7a62a85ca601f85c13e8', 'to_component_version_id': 'ver-c35cf67618df849203244857'}), + ('edge-28a95a41d986c4ce72059c14', {'edge_id': 'edge-28a95a41d986c4ce72059c14', 'from_component_version_id': 'ver-91a6e4b3011d7a0c561637e3', 'optional': False, 'relationship': 'manages-api', 'resolver': 'live-argocd-status', 'scope': 'deployment', 'source_occurrence_id': 'occ-6b26a4c39038a9cbb8d673aa', 'to_component_version_id': 'ver-6e2d82e4b9b56515b2125f93'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_import_api_resource_list.1": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-fa36a7b4e43c7144d2ee0f16', {'component_id': 'cmp-fa36a7b4e43c7144d2ee0f16', 'ecosystem': 'kubernetes', 'kind': 'platform', 'lifecycles': ['deployed'], 'metadata': {'inventory_scope': 'cluster'}, 'name': 'kubernetes', 'namespace': 'k8s.io', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:k8s/k8s.io%2Fkubernetes'}), + ('cmp-1dd1ebc31415ff4307c0b264', {'component_id': 'cmp-1dd1ebc31415ff4307c0b264', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-api', 'lifecycles': ['deployed'], 'metadata': {'api_group': 'core', 'gvk': 'core/v1/Widget'}, 'name': 'Widget', 'namespace': 'core', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-d025308d4100191c10ed65ac', {'component_id': 'cmp-1dd1ebc31415ff4307c0b264', 'component_version_id': 'ver-d025308d4100191c10ed65ac', 'evidence': ['input.json#/resources/0'], 'metadata': {'api_discovery_endpoint': '/api/v1', 'api_resource_name': 'widgets', 'namespaced': False, 'singular_name': 'widget', 'verbs': ['get', 'list'], 'short_names': ['wd'], 'categories': ['example'], 'storage_version_hash': 'example-storage-hash'}, 'resolution_state': 'resolved', 'resolved_version': 'v1'})], + 'occurrences': [('occ-c6edc736d9e8abae433dd87d', {'component_id': 'cmp-1dd1ebc31415ff4307c0b264', 'component_version_id': 'ver-d025308d4100191c10ed65ac', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/resources/0', 'lifecycle': 'deployed', 'metadata': {'endpoint': '/api/v1'}, 'occurrence_id': 'occ-c6edc736d9e8abae433dd87d', 'optional': False, 'raw_value': 'v1/widgets:Widget', 'role': 'live-kubernetes-api-discovery', 'root_id': 'cmp-fa36a7b4e43c7144d2ee0f16', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [], + 'extra_gaps': [('gap-c28951cfa4a658a517f0a9cc', {'evidence': ['input.json#/resources/1'], 'gap_id': 'gap-c28951cfa4a658a517f0a9cc', 'gap_type': 'live-api-discovery-invalid', 'message': 'API discovery endpoint /api/v1 has a non-object resource', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), ('gap-fda377435f1f3df2db12346e', {'evidence': ['input.json#/resources/2'], 'gap_id': 'gap-fda377435f1f3df2db12346e', 'gap_type': 'live-api-discovery-invalid', 'message': 'API discovery endpoint /api/v1 has a resource without name or kind', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_import_argo_item.1": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-3d5c1cbd9f2912e953741e57', {'component_id': 'cmp-3d5c1cbd9f2912e953741e57', 'ecosystem': 'argocd', 'kind': 'argo-application', 'lifecycles': ['deployed'], 'name': 'app', 'namespace': 'argocd', 'official_channel_required': False, 'official_channels': []}), + ('cmp-217b2449447cfbbacbd34ffd', {'component_id': 'cmp-217b2449447cfbbacbd34ffd', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['deployed'], 'metadata': {'chart_repository': 'https://charts.example.org'}, 'name': 'app', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-aee6fcfb3fa685f0ac8290e4', {'component_id': 'cmp-3d5c1cbd9f2912e953741e57', 'component_version_id': 'ver-aee6fcfb3fa685f0ac8290e4', 'evidence': ['input.json#/items/3'], 'metadata': {'sync_status': None, 'health_status': None, 'reconciled_at': None, 'revisions': ['1.2.4'], 'operation_phase': None, 'operation_started_at': None, 'operation_finished_at': None}, 'resolution_state': 'resolved', 'source_ref': '1.2.4'}), + ('ver-210eedc7957ed7b0d3c1c7cb', {'component_id': 'cmp-217b2449447cfbbacbd34ffd', 'component_version_id': 'ver-210eedc7957ed7b0d3c1c7cb', 'constraint': '1.2.3', 'evidence': ['input.json#/items/3/spec/source'], 'metadata': {'observed_revision': '1.2.4'}, 'resolution_state': 'resolved', 'resolved_version': '1.2.4'})], + 'occurrences': [('occ-55ca55c43df51c54482b9bab', {'component_id': 'cmp-3d5c1cbd9f2912e953741e57', 'component_version_id': 'ver-aee6fcfb3fa685f0ac8290e4', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/items/3', 'lifecycle': 'deployed', 'metadata': {'uid': None, 'resource_version': None}, 'occurrence_id': 'occ-55ca55c43df51c54482b9bab', 'optional': False, 'raw_value': 'argocd/app', 'role': 'live-argo-application', 'root_id': 'cmp-3d5c1cbd9f2912e953741e57', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-050928eb1c4cba81b402fb7f', {'component_id': 'cmp-217b2449447cfbbacbd34ffd', 'component_version_id': 'ver-210eedc7957ed7b0d3c1c7cb', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': '/items/3/spec/source', 'lifecycle': 'deployed', 'occurrence_id': 'occ-050928eb1c4cba81b402fb7f', 'optional': False, 'raw_value': 'https://charts.example.org#app@1.2.3', 'role': 'live-argo-helm-source', 'root_id': 'cmp-3d5c1cbd9f2912e953741e57', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-a2dfa1a2fdc9ddc20be3f65d', {'constraint': '1.2.3', 'edge_id': 'edge-a2dfa1a2fdc9ddc20be3f65d', 'from_component_version_id': 'ver-aee6fcfb3fa685f0ac8290e4', 'metadata': {'observed_revision': '1.2.4'}, 'optional': False, 'relationship': 'desired-source', 'resolver': 'live-argocd', 'scope': 'deployment', 'source_occurrence_id': 'occ-050928eb1c4cba81b402fb7f', 'to_component_version_id': 'ver-210eedc7957ed7b0d3c1c7cb'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_import_argo_item.2": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-3d5c1cbd9f2912e953741e57', {'component_id': 'cmp-3d5c1cbd9f2912e953741e57', 'ecosystem': 'argocd', 'kind': 'argo-application', 'lifecycles': ['deployed'], 'name': 'app', 'namespace': 'argocd', 'official_channel_required': False, 'official_channels': []}), + ('cmp-217b2449447cfbbacbd34ffd', {'component_id': 'cmp-217b2449447cfbbacbd34ffd', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['deployed'], 'metadata': {'chart_repository': 'https://charts.example.org'}, 'name': 'app', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-25c36d174210059ffc386b4a', {'component_id': 'cmp-3d5c1cbd9f2912e953741e57', 'component_version_id': 'ver-25c36d174210059ffc386b4a', 'evidence': ['input.json#/items/3'], 'metadata': {'sync_status': None, 'health_status': None, 'reconciled_at': None, 'revisions': ['1.2.4', '1.2.5'], 'operation_phase': None, 'operation_started_at': None, 'operation_finished_at': None}, 'resolution_state': 'resolved', 'source_ref': 'revisions-sha256:e15be8028bba1abeabacc24732c7d3a294c0946f16500f4f7e772d58703def28'}), + ('ver-210eedc7957ed7b0d3c1c7cb', {'component_id': 'cmp-217b2449447cfbbacbd34ffd', 'component_version_id': 'ver-210eedc7957ed7b0d3c1c7cb', 'constraint': '1.2.3', 'evidence': ['input.json#/items/3/spec/source'], 'metadata': {'observed_revision': '1.2.4'}, 'resolution_state': 'resolved', 'resolved_version': '1.2.4'})], + 'occurrences': [('occ-8505c920eb91535a7e061774', {'component_id': 'cmp-3d5c1cbd9f2912e953741e57', 'component_version_id': 'ver-25c36d174210059ffc386b4a', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/items/3', 'lifecycle': 'deployed', 'metadata': {'uid': None, 'resource_version': None}, 'occurrence_id': 'occ-8505c920eb91535a7e061774', 'optional': False, 'raw_value': 'argocd/app', 'role': 'live-argo-application', 'root_id': 'cmp-3d5c1cbd9f2912e953741e57', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-050928eb1c4cba81b402fb7f', {'component_id': 'cmp-217b2449447cfbbacbd34ffd', 'component_version_id': 'ver-210eedc7957ed7b0d3c1c7cb', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': '/items/3/spec/source', 'lifecycle': 'deployed', 'occurrence_id': 'occ-050928eb1c4cba81b402fb7f', 'optional': False, 'raw_value': 'https://charts.example.org#app@1.2.3', 'role': 'live-argo-helm-source', 'root_id': 'cmp-3d5c1cbd9f2912e953741e57', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-f6e7815c43187366b3e33fc4', {'constraint': '1.2.3', 'edge_id': 'edge-f6e7815c43187366b3e33fc4', 'from_component_version_id': 'ver-25c36d174210059ffc386b4a', 'metadata': {'observed_revision': '1.2.4'}, 'optional': False, 'relationship': 'desired-source', 'resolver': 'live-argocd', 'scope': 'deployment', 'source_occurrence_id': 'occ-050928eb1c4cba81b402fb7f', 'to_component_version_id': 'ver-210eedc7957ed7b0d3c1c7cb'})], + 'extra_gaps': [('gap-c6a94afbea4ee319aa0c4dd5', {'component_id': 'cmp-3d5c1cbd9f2912e953741e57', 'component_version_id': 'ver-25c36d174210059ffc386b4a', 'evidence': ['input.json#/items/3/status/sync'], 'gap_id': 'gap-c6a94afbea4ee319aa0c4dd5', 'gap_type': 'argo-revision-cardinality', 'message': 'Argo Application argocd/app has 1 sources but 2 observed revisions', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_import_crd_item.1": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-a3e2bcda87c32a7c25488e55', {'component_id': 'cmp-a3e2bcda87c32a7c25488e55', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-crd', 'lifecycles': ['deployed'], 'metadata': {'group': 'example.org', 'resource_kind': 'Widget'}, 'name': 'widgets.example.org', 'namespace': 'example.org', 'official_channel_required': True, 'official_channels': []}), + ('cmp-c2c71c8b4366e890876f9362', {'component_id': 'cmp-c2c71c8b4366e890876f9362', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-api', 'lifecycles': ['deployed'], 'metadata': {'api_group': 'example.org', 'gvk': 'example.org/v1/Widget', 'crd_name': 'widgets.example.org'}, 'name': 'Widget', 'namespace': 'example.org', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-36583166d25551cb104266bd', {'component_id': 'cmp-a3e2bcda87c32a7c25488e55', 'component_version_id': 'ver-36583166d25551cb104266bd', 'evidence': ['input.json#/items/2'], 'resolution_state': 'resolved', 'source_ref': 'example-id'}), + ('ver-0b87e5144f965a44a79540d2', {'artifact_digest': 'sha256:28ec55202b90e6b021793c3b91faa495efea3dfb8576f3e3e69546557c6a23db', 'component_id': 'cmp-c2c71c8b4366e890876f9362', 'component_version_id': 'ver-0b87e5144f965a44a79540d2', 'evidence': ['input.json#/items/2/spec/versions/2'], 'metadata': {'served': True, 'storage': False, 'deprecated': True, 'deprecation_warning': 'Use v2.', 'conversion': {'strategy': 'None'}}, 'resolution_state': 'resolved', 'resolved_version': 'v1'})], + 'occurrences': [('occ-24a2091fe82b2af474ce95cd', {'component_id': 'cmp-c2c71c8b4366e890876f9362', 'component_version_id': 'ver-0b87e5144f965a44a79540d2', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/items/2/spec/versions/2', 'lifecycle': 'deployed', 'occurrence_id': 'occ-24a2091fe82b2af474ce95cd', 'optional': False, 'raw_value': 'example.org/v1/Widget', 'role': 'live-crd-api', 'root_id': 'cmp-a3e2bcda87c32a7c25488e55', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-d03fcb83398f27093162a348', {'edge_id': 'edge-d03fcb83398f27093162a348', 'from_component_version_id': 'ver-36583166d25551cb104266bd', 'optional': False, 'relationship': 'defines-api', 'resolver': 'live-crd', 'scope': 'api', 'source_occurrence_id': 'occ-24a2091fe82b2af474ce95cd', 'to_component_version_id': 'ver-0b87e5144f965a44a79540d2'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_import_openapi_v3_document.1": r"""(2, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-f7840bb47bcd68a4311f7112', {'component_id': 'cmp-f7840bb47bcd68a4311f7112', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-api', 'lifecycles': ['deployed'], 'metadata': {'api_group': 'core', 'gvk': 'core/v1/Alternate'}, 'name': 'Alternate', 'namespace': 'core', 'official_channel_required': True, 'official_channels': []}), + ('cmp-1dd1ebc31415ff4307c0b264', {'component_id': 'cmp-1dd1ebc31415ff4307c0b264', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-api', 'lifecycles': ['deployed'], 'metadata': {'api_group': 'core', 'gvk': 'core/v1/Widget'}, 'name': 'Widget', 'namespace': 'core', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-4e792d73260c0be603ce23d4', {'artifact_digest': 'sha256:af12dccf05f465964d925eaefd378f2a47b09a6625144df227337852b434f5f4', 'component_id': 'cmp-f7840bb47bcd68a4311f7112', 'component_version_id': 'ver-4e792d73260c0be603ce23d4', 'evidence': ['input.json#/components/schemas/example~1alternate'], 'metadata': {'openapi_endpoint': '/openapi/v3/api/v1', 'openapi_schema_name': 'example/alternate', 'openapi_version': '3.0.0'}, 'resolution_state': 'resolved', 'resolved_version': 'v1'}), + ('ver-14c014e62d22ca5e60528738', {'artifact_digest': 'sha256:8d1fb3ef3aaf256bb8ea3661486329b37ec2b2acd137383318bb46115e1a26ff', 'component_id': 'cmp-1dd1ebc31415ff4307c0b264', 'component_version_id': 'ver-14c014e62d22ca5e60528738', 'evidence': ['input.json#/components/schemas/example~1item'], 'metadata': {'openapi_endpoint': '/openapi/v3/api/v1', 'openapi_schema_name': 'example/item', 'openapi_version': '3.0.0'}, 'resolution_state': 'resolved', 'resolved_version': 'v1'})], + 'occurrences': [('occ-9b157b5ddf230185ef793a45', + {'component_id': 'cmp-f7840bb47bcd68a4311f7112', + 'component_version_id': 'ver-4e792d73260c0be603ce23d4', + 'dependency_scope': 'runtime', + 'directness': 'direct', + 'evidence_locator': '/components/schemas/example~1alternate/x-kubernetes-group-version-kind/0', + 'lifecycle': 'deployed', + 'metadata': {'endpoint': '/openapi/v3/api/v1', 'schema_digest': 'sha256:af12dccf05f465964d925eaefd378f2a47b09a6625144df227337852b434f5f4', 'schema_name': 'example/alternate'}, + 'occurrence_id': 'occ-9b157b5ddf230185ef793a45', + 'optional': False, + 'raw_value': 'core/v1/Alternate', + 'role': 'live-kubernetes-openapi-schema', + 'root_id': 'cmp-f7840bb47bcd68a4311f7112', + 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-3e454211b5eb754e2a770ab5', + {'component_id': 'cmp-1dd1ebc31415ff4307c0b264', + 'component_version_id': 'ver-14c014e62d22ca5e60528738', + 'dependency_scope': 'runtime', + 'directness': 'direct', + 'evidence_locator': '/components/schemas/example~1item/x-kubernetes-group-version-kind/0', + 'lifecycle': 'deployed', + 'metadata': {'endpoint': '/openapi/v3/api/v1', 'schema_digest': 'sha256:8d1fb3ef3aaf256bb8ea3661486329b37ec2b2acd137383318bb46115e1a26ff', 'schema_name': 'example/item'}, + 'occurrence_id': 'occ-3e454211b5eb754e2a770ab5', + 'optional': False, + 'raw_value': 'core/v1/Widget', + 'role': 'live-kubernetes-openapi-schema', + 'root_id': 'cmp-1dd1ebc31415ff4307c0b264', + 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_import_openapi_v3_document.2": r"""(0, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-f7840bb47bcd68a4311f7112', {'component_id': 'cmp-f7840bb47bcd68a4311f7112', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-api', 'lifecycles': ['deployed'], 'metadata': {'api_group': 'core', 'gvk': 'core/v1/Alternate'}, 'name': 'Alternate', 'namespace': 'core', 'official_channel_required': True, 'official_channels': []}), + ('cmp-1dd1ebc31415ff4307c0b264', {'component_id': 'cmp-1dd1ebc31415ff4307c0b264', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-api', 'lifecycles': ['deployed'], 'metadata': {'api_group': 'core', 'gvk': 'core/v1/Widget'}, 'name': 'Widget', 'namespace': 'core', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-4e792d73260c0be603ce23d4', {'artifact_digest': 'sha256:af12dccf05f465964d925eaefd378f2a47b09a6625144df227337852b434f5f4', 'component_id': 'cmp-f7840bb47bcd68a4311f7112', 'component_version_id': 'ver-4e792d73260c0be603ce23d4', 'evidence': ['input.json#/components/schemas/example~1alternate'], 'metadata': {'openapi_endpoint': '/openapi/v3/api/v1', 'openapi_schema_name': 'example/alternate', 'openapi_version': '3.0.0'}, 'resolution_state': 'resolved', 'resolved_version': 'v1'}), + ('ver-14c014e62d22ca5e60528738', {'artifact_digest': 'sha256:8d1fb3ef3aaf256bb8ea3661486329b37ec2b2acd137383318bb46115e1a26ff', 'component_id': 'cmp-1dd1ebc31415ff4307c0b264', 'component_version_id': 'ver-14c014e62d22ca5e60528738', 'evidence': ['input.json#/components/schemas/example~1item'], 'metadata': {'openapi_endpoint': '/openapi/v3/api/v1', 'openapi_schema_name': 'example/item', 'openapi_version': '3.0.0'}, 'resolution_state': 'resolved', 'resolved_version': 'v1'})], + 'occurrences': [('occ-9b157b5ddf230185ef793a45', + {'component_id': 'cmp-f7840bb47bcd68a4311f7112', + 'component_version_id': 'ver-4e792d73260c0be603ce23d4', + 'dependency_scope': 'runtime', + 'directness': 'direct', + 'evidence_locator': '/components/schemas/example~1alternate/x-kubernetes-group-version-kind/0', + 'lifecycle': 'deployed', + 'metadata': {'endpoint': '/openapi/v3/api/v1', 'schema_digest': 'sha256:af12dccf05f465964d925eaefd378f2a47b09a6625144df227337852b434f5f4', 'schema_name': 'example/alternate'}, + 'occurrence_id': 'occ-9b157b5ddf230185ef793a45', + 'optional': False, + 'raw_value': 'core/v1/Alternate', + 'role': 'live-kubernetes-openapi-schema', + 'root_id': 'cmp-f7840bb47bcd68a4311f7112', + 'source_id': 'src-98a53e0ca7d133d11ccc09e7'}), + ('occ-3e454211b5eb754e2a770ab5', + {'component_id': 'cmp-1dd1ebc31415ff4307c0b264', + 'component_version_id': 'ver-14c014e62d22ca5e60528738', + 'dependency_scope': 'runtime', + 'directness': 'direct', + 'evidence_locator': '/components/schemas/example~1item/x-kubernetes-group-version-kind/0', + 'lifecycle': 'deployed', + 'metadata': {'endpoint': '/openapi/v3/api/v1', 'schema_digest': 'sha256:8d1fb3ef3aaf256bb8ea3661486329b37ec2b2acd137383318bb46115e1a26ff', 'schema_name': 'example/item'}, + 'occurrence_id': 'occ-3e454211b5eb754e2a770ab5', + 'optional': False, + 'raw_value': 'core/v1/Widget', + 'role': 'live-kubernetes-openapi-schema', + 'root_id': 'cmp-1dd1ebc31415ff4307c0b264', + 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "model-digest-only": r"""(('cmp-bae444d2ed75815c3da47462', 'ver-2f7fb6f98c6733bd705eee92', 'occ-2a29afdeae4619e0b7073ca2'), + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-96798a62afd2f5a456064757', {'component_id': 'cmp-96798a62afd2f5a456064757', 'ecosystem': 'local', 'kind': 'fixture', 'lifecycles': ['repository-used'], 'name': 'input.json', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-bae444d2ed75815c3da47462', {'component_id': 'cmp-bae444d2ed75815c3da47462', 'ecosystem': 'oci', 'kind': 'model-artifact', 'lifecycles': ['deployed'], 'metadata': {'fixture': True, 'artifact_identity': 'example/app'}, 'name': 'app', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-b5e5f51f6ef2c47aceaed9ef', {'component_id': 'cmp-96798a62afd2f5a456064757', 'component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'evidence': ['input.json'], 'resolution_state': 'resolved', 'source_ref': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}), + ('ver-2f7fb6f98c6733bd705eee92', {'artifact_digest': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'component_id': 'cmp-bae444d2ed75815c3da47462', 'component_version_id': 'ver-2f7fb6f98c6733bd705eee92', 'evidence': ['input.json#/model'], 'metadata': {'fixture': True, 'artifact_identity': 'example/app'}, 'resolution_state': 'resolved'})], + 'occurrences': [('occ-2a29afdeae4619e0b7073ca2', {'component_id': 'cmp-bae444d2ed75815c3da47462', 'component_version_id': 'ver-2f7fb6f98c6733bd705eee92', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/model', 'lifecycle': 'deployed', 'metadata': {'fixture': True, 'artifact_identity': 'example/app'}, 'occurrence_id': 'occ-2a29afdeae4619e0b7073ca2', 'optional': False, 'raw_value': 'example/app', 'role': 'fixture-model', 'root_id': 'cmp-96798a62afd2f5a456064757', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-969de9bc29b2c0e3ef2db6e4', {'edge_id': 'edge-969de9bc29b2c0e3ef2db6e4', 'from_component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'optional': False, 'relationship': 'provides-artifact', 'resolver': 'model-artifact-discovery', 'scope': 'runtime', 'source_occurrence_id': 'occ-2a29afdeae4619e0b7073ca2', 'to_component_version_id': 'ver-2f7fb6f98c6733bd705eee92'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "discovery-no-group": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [], + 'versions': [], + 'occurrences': [], + 'edges': [], + 'extra_gaps': [('gap-133339d52004679dc9bafee0', {'evidence': ['input.json#/resources'], 'gap_id': 'gap-133339d52004679dc9bafee0', 'gap_type': 'live-api-discovery-invalid', 'message': 'API discovery endpoint /api/v1 has no typed resources array', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "discovery-no-array": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [], + 'versions': [], + 'occurrences': [], + 'edges': [], + 'extra_gaps': [('gap-133339d52004679dc9bafee0', {'evidence': ['input.json#/resources'], 'gap_id': 'gap-133339d52004679dc9bafee0', 'gap_type': 'live-api-discovery-invalid', 'message': 'API discovery endpoint /api/v1 has no typed resources array', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "discovery-empty": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-fa36a7b4e43c7144d2ee0f16', {'component_id': 'cmp-fa36a7b4e43c7144d2ee0f16', 'ecosystem': 'kubernetes', 'kind': 'platform', 'lifecycles': ['deployed'], 'metadata': {'inventory_scope': 'cluster'}, 'name': 'kubernetes', 'namespace': 'k8s.io', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:k8s/k8s.io%2Fkubernetes'})], + 'versions': [], + 'occurrences': [], + 'edges': [], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "discovery-defaults": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-fa36a7b4e43c7144d2ee0f16', {'component_id': 'cmp-fa36a7b4e43c7144d2ee0f16', 'ecosystem': 'kubernetes', 'kind': 'platform', 'lifecycles': ['deployed'], 'metadata': {'inventory_scope': 'cluster'}, 'name': 'kubernetes', 'namespace': 'k8s.io', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:k8s/k8s.io%2Fkubernetes'}), + ('cmp-1dd1ebc31415ff4307c0b264', {'component_id': 'cmp-1dd1ebc31415ff4307c0b264', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-api', 'lifecycles': ['deployed'], 'metadata': {'api_group': 'core', 'gvk': 'core/v1/Widget'}, 'name': 'Widget', 'namespace': 'core', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-d025308d4100191c10ed65ac', {'component_id': 'cmp-1dd1ebc31415ff4307c0b264', 'component_version_id': 'ver-d025308d4100191c10ed65ac', 'evidence': ['input.json#/resources/0'], 'metadata': {'api_discovery_endpoint': '/api/v1', 'api_resource_name': 'widgets', 'namespaced': None, 'singular_name': None, 'verbs': [], 'short_names': [], 'categories': [], 'storage_version_hash': None}, 'resolution_state': 'resolved', 'resolved_version': 'v1'})], + 'occurrences': [('occ-c6edc736d9e8abae433dd87d', {'component_id': 'cmp-1dd1ebc31415ff4307c0b264', 'component_version_id': 'ver-d025308d4100191c10ed65ac', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/resources/0', 'lifecycle': 'deployed', 'metadata': {'endpoint': '/api/v1'}, 'occurrence_id': 'occ-c6edc736d9e8abae433dd87d', 'optional': False, 'raw_value': 'v1/widgets:Widget', 'role': 'live-kubernetes-api-discovery', 'root_id': 'cmp-fa36a7b4e43c7144d2ee0f16', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "openapi-empty": "(0, {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], 'components': [], 'versions': [], 'occurrences': [], 'edges': [], 'extra_gaps': [], 'discovery_inputs': [], 'node_platforms': []})", + "crd-defaults": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-a3e2bcda87c32a7c25488e55', {'component_id': 'cmp-a3e2bcda87c32a7c25488e55', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-crd', 'lifecycles': ['deployed'], 'metadata': {'group': 'unknown', 'resource_kind': 'widgets.example.org'}, 'name': 'widgets.example.org', 'namespace': 'unknown', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-d3b745598baff4e3f9e664d7', {'component_id': 'cmp-a3e2bcda87c32a7c25488e55', 'component_version_id': 'ver-d3b745598baff4e3f9e664d7', 'evidence': ['input.json#/items/0'], 'resolution_state': 'resolved', 'source_ref': '42'})], + 'occurrences': [], + 'edges': [], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "crd-no-schema": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-a3e2bcda87c32a7c25488e55', {'component_id': 'cmp-a3e2bcda87c32a7c25488e55', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-crd', 'lifecycles': ['deployed'], 'metadata': {'group': 'unknown', 'resource_kind': 'widgets.example.org'}, 'name': 'widgets.example.org', 'namespace': 'unknown', 'official_channel_required': True, 'official_channels': []}), + ('cmp-13dfb72adc6b2fdef88e4885', {'component_id': 'cmp-13dfb72adc6b2fdef88e4885', 'ecosystem': 'kubernetes', 'kind': 'kubernetes-api', 'lifecycles': ['deployed'], 'metadata': {'api_group': 'unknown', 'gvk': 'unknown/v2/widgets.example.org', 'crd_name': 'widgets.example.org'}, 'name': 'widgets.example.org', 'namespace': 'unknown', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-2515f9ff56dc88460580ff05', {'component_id': 'cmp-a3e2bcda87c32a7c25488e55', 'component_version_id': 'ver-2515f9ff56dc88460580ff05', 'evidence': ['input.json#/items/0'], 'resolution_state': 'resolved'}), + ('ver-540a6e4315ad4c15a2b8ebfd', {'component_id': 'cmp-13dfb72adc6b2fdef88e4885', 'component_version_id': 'ver-540a6e4315ad4c15a2b8ebfd', 'evidence': ['input.json#/items/0/spec/versions/0'], 'metadata': {'served': None, 'storage': None, 'deprecated': None, 'deprecation_warning': None, 'conversion': None}, 'resolution_state': 'resolved', 'resolved_version': 'v2'})], + 'occurrences': [('occ-57faec4712ee818880046814', {'component_id': 'cmp-13dfb72adc6b2fdef88e4885', 'component_version_id': 'ver-540a6e4315ad4c15a2b8ebfd', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': '/items/0/spec/versions/0', 'lifecycle': 'deployed', 'occurrence_id': 'occ-57faec4712ee818880046814', 'optional': False, 'raw_value': 'unknown/v2/widgets.example.org', 'role': 'live-crd-api', 'root_id': 'cmp-a3e2bcda87c32a7c25488e55', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-eb55216ee6572c0d71cc4317', {'edge_id': 'edge-eb55216ee6572c0d71cc4317', 'from_component_version_id': 'ver-2515f9ff56dc88460580ff05', 'optional': False, 'relationship': 'defines-api', 'resolver': 'live-crd', 'scope': 'api', 'source_occurrence_id': 'occ-57faec4712ee818880046814', 'to_component_version_id': 'ver-540a6e4315ad4c15a2b8ebfd'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", +} + + class FilesTestCase(unittest.TestCase): """Build temporary files and patch the tracked-path cache on demand.""" @@ -89,6 +629,44 @@ def track(self, *paths: str) -> None: self.enterContext(patch.dict(kr._COMMITTED_VIEW_TRACKED_PATHS, tracked)) +class ModuleBindingTests(FilesTestCase): + """Check that each checkout supplies its own registry and capture modules.""" + + def test_load_tool_modules(self) -> None: + """Load two copies while preserving canonical aliases and the import path.""" + self.assertEqual( + ( + Path(kr.__file__).resolve().parent, + Path(live.__file__).resolve().parent, + live.kr, + ), + (TOOL_ROOT, TOOL_ROOT, kr), + ) + first, second = self.root / "first", self.root / "second" + for root in (first, second): + root.mkdir() + for filename in ("knowledge_registry.py", "capture_live.py"): + shutil.copyfile(TOOL_ROOT / filename, root / filename) + with patch.dict(sys.modules, {"knowledge_registry": kr, "capture_live": live}): + before = sys.modules.copy() + original_path = sys.path.copy() + a, a_live = load_tool_modules(first) + b, b_live = load_tool_modules(second) + self.assertEqual((sys.modules, sys.path), (before, original_path)) + self.assertEqual( + tuple(Path(module.__file__).resolve() for module in (a, a_live, b, b_live)), + ( + first / "knowledge_registry.py", + first / "capture_live.py", + second / "knowledge_registry.py", + second / "capture_live.py", + ), + ) + self.assertEqual( + (a_live.kr, b_live.kr, a is b, a_live is b_live), (a, b, False, False) + ) + + class ScannerTests(FilesTestCase): """Build temporary manifests, scripts, and scanner configuration files.""" @@ -105,6 +683,18 @@ def test_normalize_codex_projection_references(self) -> None: ) escaped = data.replace(b' "' + projection, b' "\\u002e' + projection[1:]) self.assertEqual(kr.normalize_codex_projection_references(escaped), escaped) + mixed = escaped + b"[mcp_servers.other]\n" + data.split(b"\n")[-2] + b"\n" + self.assertEqual(kr.normalize_codex_projection_references(mixed), mixed) + literal = data + b"[mcp_servers.other]\n" + data.split(b"\n")[-2] + b"\n" + self.assertEqual( + kr.normalize_codex_projection_references(literal), + expected + + b'"]\n' + + b"[mcp_servers.other]\n" + + expected.split(b"\n")[-1] + + b'"]\n', + ) + self.assertEqual(kr.normalize_codex_projection_references(b""), b"") unrelated = header + b'args = ["--projection", "fixtures/projection.json"]\n' self.assertEqual(kr.normalize_codex_projection_references(unrelated), unrelated) other_flag = data.replace(b'"--projection"', b'"--projection-other"') @@ -114,44 +704,36 @@ def test_normalize_codex_projection_references(self) -> None: self.assertEqual(kr.normalize_codex_projection_references(b"\xff"), b"\xff") def test_scan_chart_lock(self) -> None: - """Record matching lock edges and flag an exact declaration mismatch.""" + """Retain declared ranges and distinguish version and repository mismatches.""" text = ( "dependencies:\n - name: child\n version: 1.2.3\n" " repository: https://charts.example.org\n" ) - self.write("Chart.yaml", "name: app\nversion: 2.0.0\n" + text) + chart = "name: app\nversion: 2.0.0\n" + text path = self.write("Chart.lock", text) self.track("Chart.lock") - builder = kr.Builder() - self.assertIsNone( - kr.scan_chart_lock(builder, self.root, path, text.encode(), text) - ) - edge = only(builder.edges) - occurrence = only(builder.occurrences) - self.assertEqual((edge["relationship"], edge["constraint"]), ("locks", "1.2.3")) - self.assertEqual( - (occurrence["evidence_locator"], occurrence["raw_value"]), - ("line:2:lock:0", "child@1.2.3"), - ) - self.assertEqual(gap_types(builder), set()) - - mismatched = text.replace("1.2.3", "1.2.4") - refused = kr.Builder() - kr.scan_chart_lock(refused, self.root, path, mismatched.encode(), mismatched) - gap = only(refused.extra_gaps) - self.assertEqual(gap["gap_type"], "helm-lock-version-mismatch") - self.assertIn("Chart.yaml declares '1.2.3'", gap["message"]) - - elsewhere = text.replace("charts.example.org", "charts.example.net") - refused = kr.Builder() - kr.scan_chart_lock(refused, self.root, path, elsewhere.encode(), elsewhere) - gap = only(refused.extra_gaps) - self.assertEqual(gap["gap_type"], "helm-lock-repository-mismatch") - self.assertIn( - "from 'https://charts.example.net', declared as 'https://charts.example.org'", - gap["message"], - ) - self.assertEqual(gap["evidence"], ["Chart.lock#L2", "Chart.yaml#L4"]) + for label, declaration, lock in ( + ("test_scan_chart_lock.1", chart, text), + ("test_scan_chart_lock.2", chart.replace("1.2.3", "^1.2.0"), text), + ("test_scan_chart_lock.3", chart, text.replace("1.2.3", "1.2.4")), + ( + "test_scan_chart_lock.4", + chart, + text.replace("charts.example.org", "charts.example.net"), + ), + ): + self.write("Chart.yaml", declaration) + check_output( + self, + EXPECTED, + label, + kr.scan_chart_lock, + kr.Builder(), + self.root, + path, + lock.encode(), + lock, + ) def test_scan_pyproject(self) -> None: """Keep exact dependency pins and optional extras while ignoring ordinary strings.""" @@ -162,27 +744,16 @@ def test_scan_pyproject(self) -> None: ) path = self.write("pyproject.toml", text) builder = kr.Builder() - self.assertIsNone( - kr.scan_pyproject(builder, self.root, path, text.encode(), text) - ) - self.assertEqual( - {row["name"] for row in fixture_rows(builder.components)}, - {"app", "example-dep", "python", "python-stdlib"}, - ) - observations = {row["role"]: row for row in fixture_rows(builder.occurrences)} - occurrence = observations["pyproject-dependency"] - self.assertEqual(occurrence["evidence_locator"], "line:5:column:17") - self.assertIs(occurrence["optional"], True) - version = builder.versions[occurrence["component_version_id"]] - self.assertEqual( - (version["resolved_version"], version["constraint"]), ("2.3.4", "==2.3.4") - ) - toolchain = observations["python-requires-version"] - self.assertEqual(toolchain["raw_value"], ">=3.11") - self.assertEqual(toolchain["evidence_locator"], "line:6") - self.assertEqual(toolchain["dependency_scope"], "build") - self.assertEqual( - builder.versions[toolchain["component_version_id"]]["constraint"], ">=3.11" + check_output( + self, + EXPECTED, + "test_scan_pyproject.1", + kr.scan_pyproject, + builder, + self.root, + path, + text.encode(), + text, ) def test_scan_containerd_hosts(self) -> None: @@ -190,54 +761,67 @@ def test_scan_containerd_hosts(self) -> None: text = ( 'server = "https://registry.example.org"\n' '[host."https://mirror.example.org"]\n' - 'capabilities = ["pull"]\nskip_verify = false\nunused = "ignore"\n' + 'capabilities = ["pull"]\noverride_path = true\nskip_verify = false\nunused = "ignore"\n' ) path = self.write("hosts.toml", text) builder = kr.Builder() - self.assertIsNone( - kr.scan_containerd_hosts(builder, self.root, path, text.encode(), text) - ) - occurrences = {row["role"]: row for row in fixture_rows(builder.occurrences)} - mirror = occurrences["containerd-registry-mirror"] - self.assertEqual( - mirror["metadata"], {"capabilities": ["pull"], "skip_verify": False} - ) - self.assertEqual(mirror["evidence_locator"], "line:2") - self.assertEqual( - occurrences["containerd-registry-server"]["evidence_locator"], "line:1" - ) - self.assertEqual( - {row["relationship"] for row in fixture_rows(builder.edges)}, - {"configures", "routes-through"}, + check_output( + self, + EXPECTED, + "test_scan_containerd_hosts.1", + kr.scan_containerd_hosts, + builder, + self.root, + path, + text.encode(), + text, ) bad = kr.Builder() - kr.scan_containerd_hosts(bad, self.root, path, b"server = [", "server = [") - self.assertEqual(gap_types(bad), {"toml-invalid"}) - self.assertEqual(bad.occurrences, {}) + check_output( + self, + EXPECTED, + "test_scan_containerd_hosts.2", + kr.scan_containerd_hosts, + bad, + self.root, + path, + b"server = [", + "server = [", + ) def test_scan_codex_config(self) -> None: """Sort remote tool names and skip local servers without URLs.""" text = ( '[mcp_servers.app]\nurl = "https://example.org/mcp"\n' 'enabled_tools = ["write", "read"]\nrequired = true\nenabled = false\n' + '[mcp_servers.default]\nurl = "https://example.net/mcp"\n' '[mcp_servers.local]\ncommand = "app"\n' ) path = self.write("config.toml", text) builder = kr.Builder() - self.assertIsNone( - kr.scan_codex_config(builder, self.root, path, text.encode(), text) - ) - occurrence = only(builder.occurrences) - self.assertEqual(occurrence["raw_value"], "https://example.org/mcp") - self.assertEqual(occurrence["dependency_scope"], "development") - self.assertEqual( - occurrence["metadata"], - {"enabled": False, "required": True, "enabled_tools": ["read", "write"]}, + check_output( + self, + EXPECTED, + "test_scan_codex_config.1", + kr.scan_codex_config, + builder, + self.root, + path, + text.encode(), + text, ) bad = kr.Builder() - kr.scan_codex_config(bad, self.root, path, b"[", "[") - self.assertEqual(gap_types(bad), {"toml-invalid"}) - self.assertEqual(bad.occurrences, {}) + check_output( + self, + EXPECTED, + "test_scan_codex_config.2", + kr.scan_codex_config, + bad, + self.root, + path, + b"[", + "[", + ) def test_scan_script_dependencies(self) -> None: """Resolve sibling pins and flag optional imports without pins.""" @@ -249,27 +833,17 @@ def test_scan_script_dependencies(self) -> None: self.write("requirements.txt", "PyYAML==1.2.3\noptimum==2.3.4\n") self.track("app.py", "requirements.txt") builder = kr.Builder() - self.assertIsNone( - kr.scan_script_dependencies(builder, self.root, path, text.encode(), text) - ) - occurrences = { - row["evidence_locator"]: row for row in fixture_rows(builder.occurrences) - } - self.assertEqual(set(occurrences), {"line:1", "line:3", "line:4"}) - pinned = builder.versions[occurrences["line:1"]["component_version_id"]] - self.assertEqual(pinned["resolved_version"], "1.2.3") - self.assertEqual( - pinned["evidence"], ["app.py#L1", "app.py#line:1", "requirements.txt#L1"] - ) - self.assertTrue(occurrences["line:3"]["optional"]) - export = occurrences["line:4"] - self.assertIs(export["optional"], False) - self.assertEqual(export["metadata"], {"distribution": "optimum"}) - self.assertEqual( - builder.versions[export["component_version_id"]]["resolved_version"], - "2.3.4", + check_output( + self, + EXPECTED, + "test_scan_script_dependencies.1", + kr.scan_script_dependencies, + builder, + self.root, + path, + text.encode(), + text, ) - self.assertEqual(gap_types(builder), {"script-dependency-pin-missing"}) def test_add_workflow_manifest_install(self) -> None: """Bind tracked manifests and report untracked inputs as gaps.""" @@ -278,25 +852,24 @@ def test_add_workflow_manifest_install(self) -> None: self.write("ignored/package.json", data) self.track("app/package.json") builder, source, component, version = local_builder() - self.assertIsNone( - kr.add_workflow_manifest_install( - builder, - self.root, - source, - component, - version, - working_directory="app", - locator="/steps/0", - ) - ) - occurrence = only(builder.occurrences) - installed = builder.versions[occurrence["component_version_id"]] - self.assertEqual(installed["resolved_version"], "1.2.3") - self.assertEqual(installed["evidence"], ["app/package.json"]) - self.assertEqual(installed["source_ref"], kr.file_hash(data)) - self.assertEqual(occurrence["raw_value"], "npm install:app/package.json") - self.assertEqual(only(builder.edges)["relationship"], "installs-manifest") - kr.add_workflow_manifest_install( + check_output( + self, + EXPECTED, + "test_add_workflow_manifest_install.1", + kr.add_workflow_manifest_install, + builder, + self.root, + source, + component, + version, + working_directory="app", + locator="/steps/0", + ) + check_output( + self, + EXPECTED, + "test_add_workflow_manifest_install.2", + kr.add_workflow_manifest_install, builder, self.root, source, @@ -305,10 +878,6 @@ def test_add_workflow_manifest_install(self) -> None: working_directory="ignored", locator="/steps/1", ) - self.assertEqual(len(builder.occurrences), 1) - gap = only(builder.extra_gaps) - self.assertEqual(gap["gap_type"], "github-actions-install-manifest-unresolved") - self.assertIn("no readable package.json in ignored", gap["message"]) class ObservationTests(unittest.TestCase): @@ -326,7 +895,11 @@ def test_add_model_artifact_observation(self) -> None: "raw_value": "example/app", "role": "fixture-model", } - model, pinned, occurrence = kr.add_model_artifact_observation( + check_output( + self, + EXPECTED, + "test_add_model_artifact_observation.1", + kr.add_model_artifact_observation, builder, source, component, @@ -336,20 +909,12 @@ def test_add_model_artifact_observation(self) -> None: artifact_digest=DIGEST, lineage_required=True, ) - metadata = { - "artifact_identity": "example/app", - "lineage_required": True, - "lineage_evidence": ["input.json#/model"], - } - self.assertEqual(builder.components[model]["metadata"], metadata) - self.assertEqual(builder.versions[pinned]["artifact_digest"], DIGEST) - self.assertEqual(builder.versions[pinned]["resolved_version"], revision) - self.assertEqual(builder.versions[pinned]["resolution_state"], "resolved") - self.assertEqual(builder.occurrences[occurrence]["metadata"], metadata) - self.assertEqual(only(builder.edges)["relationship"], "uses-model-artifact") - self.assertEqual(gap_types(builder), set()) - - _, unpinned, _ = kr.add_model_artifact_observation( + + check_output( + self, + EXPECTED, + "test_add_model_artifact_observation.2", + kr.add_model_artifact_observation, builder, source, component, @@ -357,26 +922,18 @@ def test_add_model_artifact_observation(self) -> None: **kwargs, revision="main", ) - self.assertEqual(builder.versions[unpinned]["resolution_state"], "unresolved") - self.assertEqual( - builder.versions[unpinned]["constraint"], - "immutable-revision-or-hash-required", - ) - self.assertEqual( - gap_types(builder), - { - "model-artifact-integrity-unresolved", - "model-artifact-revision-unresolved", - }, - ) def test_add_model_artifact_observation_resolves_revision_without_digest( self, ) -> None: """Resolve an immutable revision when no digest is supplied.""" builder, source, component, version = local_builder() - revision = "b" * 40 - _, revision_only, _ = kr.add_model_artifact_observation( + revision = "1.2.3" + check_output( + self, + EXPECTED, + "test_add_model_artifact_observation_resolves_revision_without_digest.1", + kr.add_model_artifact_observation, builder, source, component, @@ -389,10 +946,6 @@ def test_add_model_artifact_observation_resolves_revision_without_digest( role="fixture-model", revision=revision, ) - revision_row = builder.versions[revision_only] - self.assertEqual(revision_row["resolved_version"], revision) - self.assertNotIn("artifact_digest", revision_row) - self.assertEqual(revision_row["resolution_state"], "resolved") def test_json_walk(self) -> None: """Yield sorted object keys and escape pointer tokens while preserving list order.""" @@ -415,34 +968,145 @@ def test_json_walk(self) -> None: [("/", singleton), ("/0", {"x": False}), ("/0/x", False)], ) + def assert_projection( + self, + kind: str, + payload: Record, + surface: str, + response_type: str, + expected_kind: str | None, + ) -> None: + """Check the unchanged payload projection and the exact query sent to the runtime.""" + with patch.object( + live, "project_query_payload", wraps=live.project_query_payload + ) as project: + result = kr.enforce_exact_live_projection(payload, kind, live) + ((query, projected),) = [entry.args for entry in project.call_args_list] + self.assertEqual( + (result, asdict(query), projected), + ( + None, + { + "surface": surface, + "filename": "projection.json", + "args": (), + "expected_kind": expected_kind, + "response_type": response_type, + }, + payload, + ), + ) + def test_enforce_exact_live_projection(self) -> None: - """Accept exact server versions and refuse extra fields or unsupported types.""" - payload = {"serverVersion": {"gitVersion": "v1.2.3"}} - self.assertIsNone( - kr.enforce_exact_live_projection(payload, "server-version", live) + """Accept exact server, discovery, resource, and OpenAPI documents.""" + self.assert_projection( + "server-version", + {"serverVersion": {"gitVersion": "v1.2.3"}}, + "server-version", + "server-version", + None, ) - resources = { - "apiVersion": "v1", - "kind": "APIResourceList", - "groupVersion": "widgets.example.org/v1", - "resources": [{"name": "widgets", "kind": "Widget", "namespaced": False}], - } - self.assertIsNone( - kr.enforce_exact_live_projection(resources, "APIResourceList", live) + self.assert_projection( + "APIResourceList", + { + "apiVersion": "v1", + "kind": "APIResourceList", + "groupVersion": "widgets.example.org/v1", + "resources": [ + {"name": "widgets", "kind": "Widget", "namespaced": False} + ], + }, + "api-discovery", + "api-resource-list", + "APIResourceList", + ) + self.assert_projection( + "OpenAPIv3Document", + { + "openapi": "3.0.0", + "components": {"schemas": {"example.Widget": {"type": "object"}}}, + }, + "builtin-openapi", + "openapi-document", + "OpenAPIv3Document", + ) + self.assert_projection( + "OpenAPIv3Discovery", + { + "paths": {"api/v1": {"serverRelativeURL": "/openapi/v3/api/v1"}}, + }, + "builtin-openapi", + "openapi-index", + "OpenAPIv3Discovery", ) - with self.assertRaisesRegex( - kr.RegistryInputError, "not the exact identity-only projection" + for kind, field, values in ( + ("APIVersions", "versions", ["v1"]), + ("APIGroupList", "groups", []), ): - kr.enforce_exact_live_projection( - {**payload, "extra": "ignored"}, "server-version", live + self.assert_projection( + kind, + {"apiVersion": "v1", "kind": kind, field: values}, + "api-discovery", + "typed-object", + kind, ) - with self.assertRaisesRegex(kr.RegistryInputError, "unsupported document type"): - kr.enforce_exact_live_projection(payload, "unknown", live) + + def test_enforce_exact_typed_list_projections(self) -> None: + """Accept a typed list from each supported live object family.""" + for kind, version in ( + ("Application", "argoproj.io/v1alpha1"), + ("ApplicationSet", "argoproj.io/v1alpha1"), + ("ClusterSbomReport", "aquasecurity.github.io/v1alpha1"), + ("CustomResourceDefinition", "apiextensions.k8s.io/v1"), + ("Namespace", "v1"), + ("Node", "v1"), + ("Pod", "v1"), + ("SbomReport", "aquasecurity.github.io/v1alpha1"), + ): + with self.subTest(kind=kind): + self.assert_projection( + kind, + { + "apiVersion": version, + "kind": f"{kind}List", + "metadata": {}, + "items": [], + }, + "projection", + "typed-list", + kind, + ) + + def test_enforce_exact_live_projection_rejects_drift(self) -> None: + """Refuse additional fields, unsupported document types, and malformed projections.""" + server = {"serverVersion": {"gitVersion": "v1.2.3"}} + cases = ( + ( + {**server, "extra": "ignored"}, + "server-version", + "live export is not the exact identity-only projection", + ), + (server, "unknown", "live export has an unsupported document type"), + ({}, "server-version", "live export violates identity-only projection"), + ( + {"data": {}}, + "server-version", + "live export violates identity-only projection at /data", + ), + ) + for payload, kind, message in cases: + with self.subTest(kind=kind, message=message): + with self.assertRaises(kr.RegistryInputError) as caught: + kr.enforce_exact_live_projection(payload, kind, live) + self.assertEqual( + (type(caught.exception), str(caught.exception)), + (kr.RegistryInputError, message), + ) def test_import_api_resource_list(self) -> None: """Emit one typed resource and flag a non-object with its pointer.""" builder, source = source_builder() - group_version = "widgets.example.org/v1" + group_version = "v1" payload = { "groupVersion": group_version, "resources": [ @@ -450,29 +1114,26 @@ def test_import_api_resource_list(self) -> None: "name": "widgets", "kind": "Widget", "namespaced": False, + "verbs": ["get", "list"], + "singularName": "widget", + "shortNames": ["wd"], + "categories": ["example"], "storageVersionHash": "example-storage-hash", }, "invalid", + {"name": "missing-kind"}, ], } - self.assertIsNone( - kr.import_api_resource_list( - builder, source, payload, endpoint="/apis/widgets.example.org/v1" - ) - ) - occurrence = only(builder.occurrences) - self.assertEqual(occurrence["evidence_locator"], "/resources/0") - self.assertEqual(occurrence["raw_value"], f"{group_version}/widgets:Widget") - version = only(builder.versions) - self.assertEqual(version["metadata"]["api_resource_name"], "widgets") - self.assertIs(version["metadata"]["namespaced"], False) - self.assertEqual( - version["metadata"]["storage_version_hash"], "example-storage-hash" + check_output( + self, + EXPECTED, + "test_import_api_resource_list.1", + kr.import_api_resource_list, + builder, + source, + payload, + endpoint="/api/v1", ) - gap = only(builder.extra_gaps) - self.assertEqual(gap["gap_type"], "live-api-discovery-invalid") - self.assertEqual(gap["evidence"], ["input.json#/resources/1"]) - self.assertIn("non-object resource", gap["message"]) def test_import_openapi_v3_document(self) -> None: """Count only complete kinds and retain each schema's escaped evidence pointer.""" @@ -482,6 +1143,8 @@ def test_import_openapi_v3_document(self) -> None: "x-kubernetes-group-version-kind": [ {"group": "", "version": "v1", "kind": "Widget"}, {"group": "", "kind": "Incomplete"}, + {"group": "other.example.org", "version": "v1"}, + "invalid", ], } payload = { @@ -489,6 +1152,8 @@ def test_import_openapi_v3_document(self) -> None: "components": { "schemas": { "example/item": schema, + "example/no-gvks": {"type": "object"}, + "example/invalid": False, "example/alternate": { "type": "object", "x-kubernetes-group-version-kind": [ @@ -498,25 +1163,25 @@ def test_import_openapi_v3_document(self) -> None: } }, } - self.assertEqual( - kr.import_openapi_v3_document( - builder, source, payload, endpoint="/openapi/v3/api/v1" - ), - 2, - ) - first, second = builder.occurrences.values() - self.assertEqual(first["raw_value"], "core/v1/Alternate") - self.assertEqual(second["raw_value"], "core/v1/Widget") - version = builder.versions[second["component_version_id"]] - self.assertEqual( - version["artifact_digest"], kr.file_hash(kr.canonical_json(schema).encode()) - ) - self.assertEqual( - version["evidence"], ["input.json#/components/schemas/example~1item"] - ) - self.assertEqual( - kr.import_openapi_v3_document(builder, source, {}, endpoint="/openapi/v3"), - 0, + check_output( + self, + EXPECTED, + "test_import_openapi_v3_document.1", + kr.import_openapi_v3_document, + builder, + source, + payload, + endpoint="/openapi/v3/api/v1", + ) + check_output( + self, + EXPECTED, + "test_import_openapi_v3_document.2", + kr.import_openapi_v3_document, + builder, + source, + {}, + endpoint="/openapi/v3", ) def test_import_crd_item(self) -> None: @@ -530,26 +1195,29 @@ def test_import_crd_item(self) -> None: "names": {"kind": "Widget"}, "versions": [ {}, - {"name": "v1", "schema": schema, "served": True, "storage": False}, + False, + { + "name": "v1", + "schema": schema, + "served": True, + "storage": False, + "deprecated": True, + "deprecationWarning": "Use v2.", + }, ], + "conversion": {"strategy": "None"}, }, } - self.assertIsNone(kr.import_crd_item(builder, source, payload, 2)) - occurrence = only(builder.occurrences) - self.assertEqual(occurrence["evidence_locator"], "/items/2/spec/versions/1") - self.assertEqual(occurrence["raw_value"], "example.org/v1/Widget") - edge = only(builder.edges) - self.assertEqual(edge["relationship"], "defines-api") - self.assertEqual( - builder.versions[edge["from_component_version_id"]]["source_ref"], - "example-id", - ) - version = builder.versions[occurrence["component_version_id"]] - self.assertEqual( - version["artifact_digest"], kr.file_hash(kr.canonical_json(schema).encode()) + check_output( + self, + EXPECTED, + "test_import_crd_item.1", + kr.import_crd_item, + builder, + source, + payload, + 2, ) - self.assertIs(version["metadata"]["served"], True) - self.assertIs(version["metadata"]["storage"], False) def test_import_argo_item(self) -> None: """Prefer observed Helm revisions and flag source and revision count drift.""" @@ -565,900 +1233,256 @@ def test_import_argo_item(self) -> None: }, "status": {"operationState": {"syncResult": {"revision": "1.2.4"}}}, } - self.assertIsNone(kr.import_argo_item(builder, source, item, 3)) - occurrences = {row["role"]: row for row in fixture_rows(builder.occurrences)} - parent = occurrences["live-argo-application"] - child = occurrences["live-argo-helm-source"] - self.assertEqual(parent["raw_value"], "argocd/app") - self.assertEqual(child["evidence_locator"], "/items/3/spec/source") - version = builder.versions[child["component_version_id"]] - self.assertEqual( - (version["resolved_version"], version["constraint"]), ("1.2.4", "1.2.3") - ) - self.assertEqual( - only(builder.edges)["metadata"], {"observed_revision": "1.2.4"} + check_output( + self, + EXPECTED, + "test_import_argo_item.1", + kr.import_argo_item, + builder, + source, + item, + 3, ) - self.assertEqual(gap_types(builder), set()) item["status"]["sync"] = {"revisions": ["1.2.4", "1.2.5"]} bad, bad_source = source_builder() - kr.import_argo_item(bad, bad_source, item, 3) - gap = only(bad.extra_gaps) - self.assertEqual(gap["gap_type"], "argo-revision-cardinality") - self.assertIn("1 sources but 2 observed revisions", gap["message"]) - - -def policy_entry(template: str = CHANNEL_URI) -> Record: - """Build a policy with one available channel.""" - return { - "record": { - "record_id": "fixture-policy", - "scope": {"ecosystem": "pypi"}, - "review": {"reviewed_at": OBSERVED}, - "channels": [ - { - "channel_type": kr.OFFICIAL_CHANNEL_TYPES[0], - "disposition": "available", - "uri_template": template, - } - ], - }, - "citation": f"policy.json@{DIGEST}", - "sha256": DIGEST, - "path": "policy.json", - "preconditions": (), - } - - -def package_builder( - *, - required: bool = True, - observed: str = "1.2.3", -) -> tuple[kr.Builder, str, str]: - """Build a package and one version with stable fixture evidence.""" - builder = kr.Builder() - component = builder.add_component( - kind="library", - ecosystem="pypi", - name="app", - purl="pkg:pypi/app", - official_channel_required=required, - ) - version = builder.add_version( - component, resolved_version=observed, evidence=("input.json",) - ) - return builder, component, version - - -class ChannelRecordTests(unittest.TestCase): - """Build reviewed channel and version records from in-memory policies.""" - - def test_derived_channel(self) -> None: - """Render available template channels and degrade unresolved templates.""" - builder, component, _ = package_builder() - entry = policy_entry("https://example.org/{name}") - record = kr.derived_component_record( - entry, builder.components[component], "pkg:pypi/app", "baseline", None - ) - (channel,) = record["channels"] - self.assertEqual( - channel, - { - "channel_id": f"chn:fixture-policy:{component}:{kr.OFFICIAL_CHANNEL_TYPES[0]}", - "component_id": component, - "channel_type": kr.OFFICIAL_CHANNEL_TYPES[0], - "publisher": None, - "access": "public", - "rights": None, - "refresh_policy": "on-version-change", - "discovery_method": "generated", - "confidence": "medium", - "review_state": "accepted", - "evidence": ["pkg:pypi/app", entry["citation"]], - "availability_state": "available", - "canonical_uri": CHANNEL_URI, - "version_strategy": "per-version", - "gap": None, - }, - ) - - entry["record"]["channels"][0]["uri_template"] = "https://example.org/{missing}" - record = kr.derived_component_record( - entry, builder.components[component], "pkg:pypi/app", "baseline", None - ) - (channel,) = record["channels"] - self.assertIsNone(channel["canonical_uri"]) - self.assertEqual(channel["availability_state"], "unresolved") - self.assertEqual( - channel["gap"], - { - "state": "unresolved", - "reason": "uri-template-unrenderable: https://example.org/{missing}", - "blocking": False, - "evidence": [entry["citation"]], - "next_action": "probe-wave", - }, + check_output( + self, + EXPECTED, + "test_import_argo_item.2", + kr.import_argo_item, + bad, + bad_source, + item, + 3, + ) + + def test_observation_defaults(self) -> None: + """Keep the complete output for absent discovery, schemas, and CRD versions.""" + builder, source = source_builder() + check_output( + self, + EXPECTED, + "discovery-no-group", + kr.import_api_resource_list, + builder, + source, + {"resources": []}, + endpoint="/api/v1", ) - - def test_derived_channel_cites_rendered_uri_in_gap(self) -> None: - """Cite a renderable URI that still needs verification.""" - builder, component, _ = package_builder() - entry = policy_entry("https://example.org/{name}") - spec = entry["record"]["channels"][0] - spec.update( - disposition="derived-unverified", - gap_reason="pending verification", + builder, source = source_builder() + check_output( + self, + EXPECTED, + "discovery-no-array", + kr.import_api_resource_list, + builder, + source, + {"groupVersion": "v1"}, + endpoint="/api/v1", ) - record = kr.derived_component_record( - entry, builder.components[component], "pkg:pypi/app", "baseline", None + builder, source = source_builder() + check_output( + self, + EXPECTED, + "discovery-empty", + kr.import_api_resource_list, + builder, + source, + {"groupVersion": "v1", "resources": []}, + endpoint="/api/v1", ) - (channel,) = record["channels"] - self.assertEqual( - channel["gap"], + builder, source = source_builder() + check_output( + self, + EXPECTED, + "discovery-defaults", + kr.import_api_resource_list, + builder, + source, { - "state": "unresolved", - "reason": "pending verification", - "blocking": False, - "evidence": [f"derived-uri:{CHANNEL_URI}", entry["citation"]], - "next_action": "probe-wave", - }, - ) - - def test_component_table_channel(self) -> None: - """Carry catalog provenance into available channels and explicit gaps.""" - builder, component, _ = package_builder() - entry = policy_entry() - entry["record"]["tables"] = { - kr.CHANNEL_POLICY_PROVENANCE_TABLE: { - "fixture": "https://example.net/catalog" + "groupVersion": "v1", + "resources": [{"kind": "Widget", "name": "widgets"}], }, - } - row = { - "channel_type": kr.OFFICIAL_CHANNEL_TYPES[0], - "disposition": "available", - "canonical_uri": CHANNEL_URI, - "provenance": {"pass": "2", "refs": ["fixture", "missing"]}, - "probe": {"status": 200, "final_url": CHANNEL_URI}, - } - record = kr.derived_component_record( - entry, - builder.components[component], - "pkg:pypi/app", - "baseline", - None, - row_set={"channels": [row]}, - ) - (channel,) = record["channels"] - self.assertEqual(channel["discovery_method"], "inferred") - self.assertEqual(channel["version_strategy"], "catalog-only") - self.assertEqual(channel["canonical_uri"], CHANNEL_URI) - self.assertEqual( - channel["evidence"], - sorted( - [ - "https://example.net/catalog", - "pkg:pypi/app", - entry["citation"], - f"probe:200:{CHANNEL_URI}", - "research-pass:2", - ] - ), + endpoint="/api/v1", ) - row.update(disposition="unresolved", reason="catalog unavailable") - record = kr.derived_component_record( - entry, - builder.components[component], - "pkg:pypi/app", - "baseline", - None, - row_set={"channels": [row]}, + def test_schema_and_crd_defaults(self) -> None: + """Keep whole observations for empty schemas and missing CRD versions or digests.""" + builder, source = source_builder() + check_output( + self, + EXPECTED, + "openapi-empty", + kr.import_openapi_v3_document, + builder, + source, + {"components": {"schemas": {}}}, + endpoint="/openapi/v3", ) - (channel,) = record["channels"] - self.assertIsNone(channel["canonical_uri"]) - self.assertEqual(channel["gap"]["reason"], "catalog unavailable") - self.assertEqual(channel["gap"]["next_action"], "probe-wave") - - def test_derived_component_record(self) -> None: - """Stamp the policy and strip fragment suffixes from document template values.""" - builder, component, _ = package_builder() - entry = policy_entry("{evidence_document}") - live_pointer = "live-export:fixture.json#/items/0" - component_row = {**builder.components[component], "namespace": "example"} - record = kr.derived_component_record( - entry, - component_row, - "pkg:pypi/app", - "baseline", - "input.json", - live_pointer, + builder, source = source_builder() + check_output( + self, + EXPECTED, + "crd-defaults", + kr.import_crd_item, + builder, + source, + {"metadata": {"name": "widgets.example.org", "resourceVersion": "42"}}, + 0, ) - self.assertEqual(record["record_id"], f"record:fixture-policy:{component}") - self.assertEqual( - record["review"], + builder, source = source_builder() + check_output( + self, + EXPECTED, + "crd-no-schema", + kr.import_crd_item, + builder, + source, { - "status": "accepted", - "reviewed_by": f"{kr.CHANNEL_POLICY_REVIEWER_PREFIX}fixture-policy@{DIGEST}", - "reviewed_at": OBSERVED, - "evidence": ["baseline:baseline", entry["citation"]], + "metadata": {"name": "widgets.example.org"}, + "spec": {"versions": [{"name": "v2"}]}, }, - ) - self.assertEqual(record["component"]["registry_identity"], "pkg:pypi/app") - self.assertEqual(record["component"]["namespace"], "example") - self.assertEqual(record["component"]["registry_kind"], "library") - self.assertEqual(record["component"]["kind"], "library") - self.assertEqual((record["versions"], record["snapshots"]), ([], [])) - (channel,) = record["channels"] - self.assertEqual(channel["canonical_uri"], "live-export:fixture.json") - self.assertEqual( - channel["evidence"], - sorted( - [ - "input.json", - live_pointer, - "pkg:pypi/app", - entry["citation"], - ] - ), + 0, ) - def test_snapshot_reviewed_version_entry(self) -> None: - """Skip digestless resolved images and select the next expressible version.""" - component = "cmp-fixture" - version = { - "component_version_id": "ver-fixture", - "resolution_state": "resolved", - "resolved_version": "1.2.3", - "artifact_digest": DIGEST, - "platform": "linux/amd64", - "evidence": ["z.json", "a.json", "a.json"], - "metadata": {"observed_at": "invalid"}, - } - selected = kr.snapshot_reviewed_version_entry( + def test_model_artifact_digest_only(self) -> None: + """Resolve content with a digest even when the artifact has no revision.""" + builder, source, component, version = local_builder() + check_output( + self, + EXPECTED, + "model-digest-only", + kr.add_model_artifact_observation, + builder, + source, component, - [ - {**version, "component_version_id": "ver-later"}, - { - **version, - "component_version_id": "ver-earlier", - "artifact_digest": None, - }, - version, - ], - OBSERVED, + version, ecosystem="oci", - kind="image", + identity="example/app", + name="app", + locator="/model", + raw_value="example/app", + role="fixture-model", + artifact_digest=DIGEST, + lifecycle="deployed", + metadata={"fixture": True}, + root_relationship="provides-artifact", ) - self.assertEqual( - selected, + + def test_argo_empty_status(self) -> None: + """Record an application with no observed revision, sources, or resources.""" + builder, source = source_builder() + check_output( + self, + EXPECTED, + "argo-empty", + kr.import_argo_item, + builder, + source, { - "component_version_id": "ver-fixture", - "component_id": component, - "purl": None, - "constraint": None, - "resolved_version": "1.2.3", - "source_ref": None, - "artifact_digest": DIGEST, - "platform": "linux/amd64", - "build_metadata": {}, - "release_time": None, - "observed_at": OBSERVED, - "valid_from": None, - "valid_to": None, - "resolution_state": "resolved", - "evidence": ["a.json", "z.json"], + "kind": "ApplicationSet", + "metadata": {"name": "app", "namespace": "example"}, }, - ) - self.assertIsNone( - kr.snapshot_reviewed_version_entry( - component, - [{**version, "artifact_digest": None}], - OBSERVED, - ecosystem="oci", - kind="image", - ) - ) - - -class ManifestFixtureTestCase(FilesTestCase): - """Patch the registry's __file__ and draft202012_validator for fixture manifests.""" - - def setUp(self) -> None: - """Isolate generator files and the schema engine from behavioral tests.""" - super().setUp() - generator = self.write(kr.GENERATOR_SOURCE_REF, "# fixture generator\n") - self.write(kr.DISCOVERY_SCHEMA_RELATIVE, "{}") - self.enterContext(patch.object(kr, "__file__", str(generator))) - validator = Mock() - validator.iter_errors.return_value = () - self.enterContext( - patch.object(kr, "draft202012_validator", return_value=validator) + 0, ) - def receipt(self, uri: str, subject: str, data: bytes) -> Record: - """Store receipt bytes under their digest and return a receipt row.""" - content_hash = "sha256:" + hashlib.sha256(data).hexdigest() - cas_path = f"cas/{content_hash[7:]}" - self.write(cas_path, data) + @staticmethod + def argo_multi_source_item() -> Record: + """Describe an application with observed sources, images, and API resources.""" return { - "canonical_uri": uri, - "resolved_uri": uri, - "channel_ids": [subject], - "observed_at": OBSERVED, - "fetched_at": OBSERVED, - "content_hash": content_hash, - "cas_path": cas_path, - "status": "verified", - } - - def write_receipts(self, *rows: Record) -> None: - """Write the receipt JSONL consumed by registry binders.""" - if len(rows) > MAX_FIXTURE_ROWS: - raise AssertionError( - f"receipt batch exceeds {MAX_FIXTURE_ROWS} fixture rows" - ) - self.write( - "receipts/input.jsonl", "".join(json.dumps(row) + "\n" for row in rows) - ) - - def snapshot_fixture(self) -> tuple[Record, Record, str, str]: - """Create one accepted channel and its bindable package version.""" - builder, component, version = package_builder() - record = kr.derived_component_record( - policy_entry(), - builder.components[component], - "pkg:pypi/app", - "baseline", - "input.json", - ) - (channel,) = record["channels"] - builder.components[component]["official_channels"] = [channel] - return builder.manifest(), record, str(channel["channel_id"]), version - - def oci_receipt(self, version: str, architecture: str) -> Record: - """Write single-platform OCI manifest and config bytes with matching digests.""" - config = json.dumps({"os": "linux", "architecture": architecture}).encode() - config_hash = "sha256:" + hashlib.sha256(config).hexdigest() - config_path = f"cas/{config_hash[7:]}" - self.write(config_path, config) - data = json.dumps( - { - "schemaVersion": 2, - "mediaType": OCI_MEDIA, - "config": {"digest": config_hash}, - "layers": [], - } - ).encode() - row = self.receipt(OCI_URI, version, data) - row["media_type"] = OCI_MEDIA - row["coordinates"] = { - "oci": { - "registry": OCI_REGISTRY, - "repository": OCI_REPOSITORY, - "reference": "1.2.3", - "reference_kind": "tag", - "resolved_digest": row["content_hash"], - "kind": "manifest", - "config_content_hash": config_hash, - "config_cas_path": config_path, - "platforms": [f"linux/{architecture}"], - "children": [], - "excluded": [], - } - } - return row - - -class ChannelWaveTests(ManifestFixtureTestCase): - """Build channel policy waves, snapshot receipts, and comparison manifests.""" - - def test_derive_channel_records(self) -> None: - """Emit matching records and samples and skip failed preconditions.""" - builder, component, _ = package_builder() - baseline = builder.manifest() - entry = policy_entry() - records, samples, summary = kr.derive_channel_records(baseline, [entry]) - ((identifier, record),) = records - self.assertEqual(identifier, component) - self.assertEqual(record["channels"][0]["canonical_uri"], CHANNEL_URI) - self.assertEqual(summary["records_emitted"], 1) - self.assertEqual( - summary["expected_accepted_slots_delta"], len(kr.OFFICIAL_CHANNEL_TYPES) - ) - ((name, sample),) = samples - self.assertEqual(name, "sample-pypi.json") - self.assertEqual(sample["policy_path"], "policy.json") - self.assertEqual( - sample["entries"], - [ - { - "component_id": component, - "name": "app", - "purl": "pkg:pypi/app", - "channels": [ - { - "channel_type": kr.OFFICIAL_CHANNEL_TYPES[0], - "availability_state": "available", - "canonical_uri": CHANNEL_URI, - } - ], - } - ], - ) - - entry["preconditions"] = [("name", re.compile("^other$"))] - records, _, summary = kr.derive_channel_records(baseline, [entry]) - self.assertEqual(records, []) - self.assertEqual(summary["skipped"], {"precondition-mismatch": 1}) - with self.assertRaisesRegex( - kr.RegistryInputError, "derive-channels baseline is invalid" - ): - kr.derive_channel_records({}, [entry]) - - def test_channel_wave_gate(self) -> None: - """Check the declared wave size and reject a component delta.""" - builder, _, _ = package_builder() - baseline = builder.manifest() - accepted = kr.channel_wave_gate( - baseline, baseline, policies=[], expected_matched=0 - ) - self.assertIs(accepted["pass"], True) - refused = kr.channel_wave_gate( - baseline, baseline, policies=[], expected_matched=1 - ) - self.assertIs(refused["pass"], False) - self.assertEqual( - refused["checks"]["accepted-slots"], - { - "pass": False, - "baseline": 0, - "merged": 0, - "delta": 0, - "expected_delta": 0, - "policy_stamped_components": 0, - "baseline_policy_stamped_components": 0, - "wave_policy_stamped_components": 0, - "reclassified_accepted_slots": 0, - "expected_matched": 1, + "kind": "Application", + "metadata": { + "name": "app", + "namespace": "example", + "uid": "fixture-id", + "resourceVersion": "42", }, - ) - - added = builder.add_component( - kind="library", - ecosystem="pypi", - name="other", - purl="pkg:pypi/other", - official_channel_required=False, - ) - changed = kr.channel_wave_gate( - baseline, builder.manifest(), policies=[], expected_matched=0 - ) - self.assertIs(changed["pass"], False) - self.assertEqual( - changed["checks"]["zero-new-components"], - {"pass": False, "new_component_ids": [added], "removed_component_ids": []}, - ) - - def test_bind_channel_snapshot_receipts(self) -> None: - """Bind verified CAS bytes and report receipts for unknown channels.""" - baseline, record, channel, version = self.snapshot_fixture() - component = record["component"]["component_id"] - row = self.receipt(CHANNEL_URI, channel, b"fixture snapshot\n") - other = {**row, "channel_ids": ["chn:other"]} - self.write_receipts(row, other) - summary = kr.bind_channel_snapshot_receipts( - [(component, record)], baseline, str(self.root) - ) - self.assertEqual( - summary, - { - "receipts_dir": self.root.as_posix(), - "receipt_rows": 2, - "receipt_rows_rejected": 0, - "rejected_receipts": [], - "channels_receipted": 2, - "channels_bound": 1, - "bound_channel_ids_digest": kr.digest_ids([channel]), - "channels_unbound": [ + "status": { + "sync": {"status": "Synced"}, + "health": {"status": "Healthy"}, + "reconciledAt": OBSERVED, + "operationState": { + "phase": "Succeeded", + "startedAt": OBSERVED, + "finishedAt": LATER, + "syncResult": { + "revisions": ["b" * 40, "2.0.1"], + "images": ["registry.example.org/example/app@" + DIGEST], + }, + }, + "summary": { + "images": [ + "registry.example.org/example/app@" + "sha256:" + "b" * 64, + "{{ .Values.image }}", + 42, + ] + }, + "resources": [ + False, { - "channel_id": "chn:other", - "reason": "input.jsonl:2: receipt does not match a derived available channel", - } + "group": "apps", + "version": "v1", + "kind": "Deployment", + "name": "app", + "namespace": "example", + "status": "Synced", + }, + {}, ], }, - ) - (snapshot,) = record["snapshots"] - self.assertEqual(snapshot["component_version_id"], version) - self.assertEqual( - snapshot["snapshot_id"], f"snap:{channel}:{row['content_hash'][7:19]}" - ) - self.assertEqual(snapshot["content_hash"], row["content_hash"]) - self.assertEqual(record["versions"][0]["observed_at"], OBSERVED) - - def test_bind_channel_snapshot_receipts_rejects_uri_mismatch(self) -> None: - """Refuse a verified receipt with a known channel ID and a different URI.""" - baseline, record, channel, _ = self.snapshot_fixture() - component = record["component"]["component_id"] - row = self.receipt("https://example.net/app", channel, b"fixture snapshot\n") - self.write_receipts(row) - summary = kr.bind_channel_snapshot_receipts( - [(component, record)], baseline, str(self.root) - ) - self.assertEqual(summary["receipt_rows_rejected"], 0) - self.assertEqual(summary["channels_bound"], 0) - self.assertEqual( - summary["channels_unbound"], - [ - { - "channel_id": channel, - "reason": "input.jsonl:1: receipt canonical_uri does not match the channel", - } - ], - ) - self.assertEqual(record["snapshots"], []) - - def test_channel_snapshot_gate(self) -> None: - """Require a traced snapshot for each bindable receipt.""" - baseline, record, channel, _ = self.snapshot_fixture() - component = record["component"]["component_id"] - row = self.receipt(CHANNEL_URI, channel, b"fixture snapshot\n") - self.write_receipts(row) - refused = kr.channel_snapshot_gate( - baseline, baseline, receipts_dir=str(self.root) - ) - self.assertIs(refused["pass"], False) - self.assertEqual( - refused["checks"]["snapshot-arithmetic"]["uncredited_expected"], [channel] - ) - self.assertEqual( - refused["checks"]["no-silent-drop"]["dropped_verified_channels"], [channel] - ) - - kr.bind_channel_snapshot_receipts( - [(component, record)], baseline, str(self.root) - ) - (original,) = baseline["components"] - changed = {**original, "official_channel_snapshots": record["snapshots"]} - merged = kr.seal_manifest({**baseline, "components": [changed]}) - accepted = kr.channel_snapshot_gate( - baseline, merged, receipts_dir=str(self.root) - ) - self.assertIs(accepted["pass"], True, accepted) - self.assertEqual( - accepted["checks"]["snapshot-arithmetic"]["credited_channels"], 1 - ) - self.assertEqual( - accepted["checks"]["added-snapshots-trace"], - { - "pass": True, - "added_snapshots": 1, - "violations": [], - }, - ) - - added_builder, _, added_id = package_builder(observed="1.2.4") - added = only(added_builder.versions) - changed = kr.seal_manifest({**merged, "versions": [*merged["versions"], added]}) - drift = kr.channel_snapshot_gate(baseline, changed, receipts_dir=str(self.root)) - self.assertIs(drift["pass"], False) - self.assertEqual(drift["checks"]["merged-valid"], {"pass": True, "errors": []}) - self.assertEqual( - drift["checks"]["zero-new-versions"], - { - "pass": False, - "versions": 2, - "new_version_ids": [added_id], - "removed_version_ids": [], - }, - ) - - -class IdentityTests(ManifestFixtureTestCase): - """Build Git and OCI receipts and compare control, treatment, and anchor manifests.""" - - def test_bind_gitops_identity(self) -> None: - """Bind a verified commit to a mutable ref without reminting the version.""" - builder = kr.Builder() - component = builder.add_component( - kind="git-repository", - ecosystem="git", - name="self", - identity="git:repository:self", - metadata={"self_repository": True}, - official_channel_required=False, - ) - version = builder.add_version( - component, source_ref="main", evidence=("input.json",) - ) - other = builder.add_component( - kind="git-repository", - ecosystem="git", - name="other", - identity="git:repository:other", - metadata={"self_repository": False}, - official_channel_required=False, - ) - builder.add_version(other, source_ref="main", evidence=("input.json",)) - baseline = builder.manifest() - data = ( - f"tree {'a' * 40}\nauthor Example 1767323045 +0000\n" - "committer Example 1767323045 +0000\n\nfixture\n" - ).encode() - commit = hashlib.sha1(f"commit {len(data)}\0".encode() + data).hexdigest() - row = self.receipt( - "https://git.example.org/example/app", - f"chn:fixture:{component}:source", - data, - ) - row["channel_ids"].append(f"chn:fixture:{other}:source") - row.update(media_type=kr.GITOPS_COMMIT_MEDIA_TYPE, upstream_ref=commit) - self.write_receipts(row) - fragment, summary = kr.bind_gitops_identity( - baseline, str(self.root), observed_ref="MAIN" - ) - self.assertEqual(summary["observed_ref"], "main") - self.assertEqual(summary["commits"], [commit]) - self.assertEqual(summary["versions_bound"], 1) - self.assertEqual(summary["skipped"], {"not-a-self-repository-component": 1}) - (bound,) = fragment["versions"] - self.assertEqual(bound["component_version_id"], version) - self.assertEqual( - bound["metadata"][kr.GITOPS_OBSERVATION_KEY], - { - "evidence_cas_path": row["cas_path"], - "evidence_content_hash": row["content_hash"], - "observed_at": OBSERVED, - "observed_commit": commit, - "observed_ref": "main", - "receipt_canonical_uri": row["canonical_uri"], - "resolver": "git-commit-object-receipt", + "spec": { + "sources": [ + { + "repoURL": "https://git.example.org/example/app.git", + "path": "app", + "targetRevision": "main", + }, + { + "repoURL": "https://charts.example.org", + "chart": "app", + "targetRevision": "2.0.0", + }, + ] }, - ) - with self.assertRaisesRegex(kr.RegistryInputError, "is not a mutable ref"): - kr.bind_gitops_identity(baseline, str(self.root), observed_ref=commit) + } - def test_bind_oci_identity(self) -> None: - """Bind OCI manifest identity and reject conflicting receipts for one tag.""" + def test_argo_status_and_multiple_sources(self) -> None: + """Capture deployment metadata, observed images, Git paths, and API resources.""" builder, source = source_builder() - _, version, _ = builder.add_image( - f"{OCI_REGISTRY}/{OCI_REPOSITORY}:1.2.3", source, "/image", "fixture-image" - ) - baseline = builder.manifest() - row = self.oci_receipt(version, "amd64") - newer = {**row, "observed_at": LATER, "fetched_at": LATER} - self.write_receipts(newer, row) - fragment, summary = kr.bind_oci_identity(baseline, str(self.root)) - self.assertEqual(summary["versions_bound"], 1) - self.assertEqual(summary["planned_refs_unreceipted"], []) - (bound,) = fragment["versions"] - self.assertEqual(bound["component_version_id"], version) - observation = bound["metadata"][kr.OCI_OBSERVATION_KEY] - self.assertEqual(observation["resolved_digest"], row["content_hash"]) - self.assertEqual(observation["platforms"], ["linux/amd64"]) - self.assertEqual(observation["receipt_canonical_uri"], OCI_URI) - self.assertEqual(observation["observed_at"], LATER) - - conflicting = self.oci_receipt(version, "arm64") - self.write_receipts(row, conflicting) - with self.assertRaisesRegex( - kr.RegistryInputError, "disagree on the identity.*2 distinct manifests" - ): - kr.bind_oci_identity(baseline, str(self.root)) - - def test_identity_gate(self) -> None: - """Require every added version to appear in the expected plan.""" - builder, component, _ = package_builder(required=False) - control = builder.manifest() - new_version = builder.add_version(component, resolved_version="1.2.4") - treatment = builder.manifest() - self.write_receipts() - refused = kr.identity_gate( - control, treatment, receipts_dir=str(self.root), anchor=control - ) - self.assertIs(refused["pass"], False) - self.assertEqual( - refused["checks"]["version-delta-justified"], - { - "pass": False, - "versions": 2, - "declared_new": 0, - "declared_removed": 0, - "undeclared_new_version_ids": [new_version], - "undeclared_removed_version_ids": [], - }, - ) - accepted = kr.identity_gate( - control, - treatment, - receipts_dir=str(self.root), - anchor=control, - expected_plan={"expected_new_version_ids": [new_version]}, - ) - self.assertIs(accepted["pass"], True, accepted) - self.assertEqual( - accepted["checks"]["generation-anchored"]["anchor_manifest_id"], - control["manifest_id"], - ) - self.assertEqual( - accepted["checks"]["version-delta-justified"]["undeclared_new_version_ids"], - [], + check_output( + self, + EXPECTED, + "argo-observed-sources", + kr.import_argo_item, + builder, + source, + self.argo_multi_source_item(), + 1, ) - anchor = kr.Builder().manifest() - drift = kr.identity_gate( - control, - treatment, - receipts_dir=str(self.root), - anchor=anchor, - expected_plan={"expected_new_version_ids": [new_version]}, - ) - self.assertIs(drift["pass"], False) - self.assertEqual( - drift["checks"]["generation-anchored"], - { - "pass": False, - "anchor_manifest_id": anchor["manifest_id"], - "control_identity_blocking": 0, - "violations": ["control components differ from the anchor generation"], + def test_argo_git_target_without_observed_revision(self) -> None: + """Retain a Git target and repository-name fallback without sync evidence.""" + builder, source = source_builder() + item = { + "metadata": {"name": "app"}, + "spec": { + "sources": [ + False, + { + "repoURL": "https://git.example.org/example/app.git", + "targetRevision": "main", + }, + ] }, - ) - - -class MergeTests(ManifestFixtureTestCase): - """Build manifest candidates and conflicting records for strict merges.""" - - def test_strict_merge_candidate_value(self) -> None: - """Union evidence and keep the latest timestamp while rejecting scalar conflicts.""" - left = { - "evidence": ["z.json", "a.json"], - "metadata": {"observed_at": LATER}, - "source_ref": "1.2.3", - } - right = { - "evidence": ["b.json", "a.json"], - "metadata": {"observed_at": OBSERVED}, - "source_ref": "1.2.3", } - result = kr.strict_merge_candidate_record( - "versions", "ver-fixture", left, right - ) - self.assertEqual( - result, - { - "evidence": ["a.json", "b.json", "z.json"], - "metadata": {"observed_at": LATER}, - "source_ref": "1.2.3", - }, - ) - self.assertEqual( - kr.strict_merge_candidate_record("versions", "ver-fixture", right, left), - result, - ) - with self.assertRaisesRegex( - kr.RegistryInputError, - "merge conflict for versions record ver-fixture at /source_ref", - ): - kr.strict_merge_candidate_record( - "versions", "ver-fixture", left, {**right, "source_ref": "1.2.4"} - ) - - def test_merge_manifests(self) -> None: - """Produce deterministic merged evidence and lineage from temporal candidates.""" - builder, component, version = package_builder(required=False) - older = kr.seal_manifest( - { - **builder.manifest(), - "observation": { - "observed_at": OBSERVED, - "source_valid_at": OBSERVED, - "source_valid_time_basis": "git-commit-committer-time", - }, - } - ) - builder.add_version( - component, resolved_version="1.2.3", evidence=("other.json",) - ) - newer = kr.seal_manifest( - { - **builder.manifest(base_manifest_id=older["manifest_id"]), - "observation": {**older["observation"], "observed_at": LATER}, - } - ) - merged = kr.merge_manifests([newer, older]) - self.assertEqual(merged, kr.merge_manifests([older, newer])) - self.assertEqual(merged["observation"], newer["observation"]) - self.assertEqual( - merged["merge_lineage"], - { - "selection_policy": kr.MERGE_SELECTION_POLICY, - "input_manifest_ids": sorted( - [older["manifest_id"], newer["manifest_id"]] - ), - "current_manifest_id": newer["manifest_id"], - "previous_manifest_id": older["manifest_id"], - }, - ) - (merged_version,) = merged["versions"] - self.assertEqual(merged_version["component_version_id"], version) - self.assertEqual(merged_version["evidence"], ["input.json", "other.json"]) - with self.assertRaisesRegex( - kr.RegistryInputError, "merge requires at least one candidate manifest" - ): - kr.merge_manifests([]) - with self.assertRaisesRegex( - kr.RegistryInputError, "merge input 1 is invalid: schema_version must equal" - ): - kr.merge_manifests([older, {**newer, "schema_version": "invalid"}]) - - -class CommandTests(FilesTestCase): - """Build temporary CLI paths and capture registry and live helper output.""" - - def test_capture_live_main(self) -> None: - """Reject a non-UTC observation time before capture opens any inputs.""" - output = self.root / "capture" - args = [ - "--output-dir", - str(output), - "--kubeconfig", - str(self.root / "unused.yaml"), - "--git-commit", - "a" * 40, - "--observed-at", - "2026-01-02", - ] - with ( - redirect_stdout(io.StringIO()) as stdout, - redirect_stderr(io.StringIO()) as stderr, - ): - self.assertEqual(live.main(args), 2) - self.assertEqual(stdout.getvalue(), "") - self.assertEqual( - stderr.getvalue(), - "capture failed: observed-at must be an exact UTC second\n", + check_output( + self, + EXPECTED, + "argo-git-target", + kr.import_argo_item, + builder, + source, + item, + 0, ) - self.assertFalse(output.exists()) - - def test_main(self) -> None: - """Write canonical capabilities once and refuse an existing output file.""" - output = self.root / "capabilities.json" - args = ["capabilities", "--output", str(output)] - with ( - redirect_stdout(io.StringIO()) as stdout, - redirect_stderr(io.StringIO()) as stderr, - ): - self.assertEqual(kr.main(args), 0) - self.assertEqual((stdout.getvalue(), stderr.getvalue()), ("", "")) - expected = { - "allowed": [ - "discover-repo", - "import-live", - "import-reviewed", - "merge", - "derive-channels", - "bind-identity", - "bind-oci-identity", - "wave-gate", - "snapshot-gate", - "identity-gate", - "validate", - "summarize", - "coverage", - "gaps", - ], - "network_access": False, - "cluster_access": "read-only capture helper only", - "source_acquisition": False, - "source_admission": False, - "retrieval_release": False, - "signing": False, - "pointer_mutation": False, - "production_mutation": False, - } - original = output.read_bytes() - self.assertEqual(json.loads(original), expected) - self.assertEqual(original, (kr.canonical_json(expected) + "\n").encode()) - with redirect_stderr(io.StringIO()) as stderr: - self.assertEqual(kr.main(args), 2) - self.assertIn("output must be a fresh non-symlink file", stderr.getvalue()) - self.assertEqual(output.read_bytes(), original) diff --git a/tools/knowledge-registry/tests/test_registry_function_net_channels.py b/tools/knowledge-registry/tests/test_registry_function_net_channels.py new file mode 100644 index 0000000..432fb85 --- /dev/null +++ b/tools/knowledge-registry/tests/test_registry_function_net_channels.py @@ -0,0 +1,1451 @@ +# SPDX-FileCopyrightText: 2026 Lusoris +# SPDX-License-Identifier: EUPL-1.2 + +from __future__ import annotations + +import ast +import hashlib +import json +import re +import sys +from pathlib import Path +from unittest.mock import Mock, patch + +# Resolve sibling fixtures in this checkout even when another net was loaded earlier. +fixture_dir = Path(__file__).resolve().parent +with patch.dict(sys.modules): + for sibling in ("test_registry_function_net",): + cached_path = getattr(sys.modules.get(sibling), "__file__", None) + if cached_path is None or Path(cached_path).resolve().parent != fixture_dir: + sys.modules.pop(sibling, None) + with patch.object(sys, "path", [str(fixture_dir), *sys.path]): + from test_registry_function_net import ( + CHANNEL_URI, + DIGEST, + LATER, + MAX_FIXTURE_ROWS, + OBSERVED, + OCI_MEDIA, + OCI_REGISTRY, + OCI_REPOSITORY, + OCI_URI, + FilesTestCase, + Record, + check_output, + kr, + only, + source_builder, + ) + + def policy_entry(template: str = CHANNEL_URI) -> Record: + """Build a policy with one available channel.""" + return { + "record": { + "record_id": "fixture-policy", + "scope": {"ecosystem": "pypi"}, + "review": {"reviewed_at": OBSERVED}, + "channels": [ + { + "channel_type": kr.OFFICIAL_CHANNEL_TYPES[0], + "disposition": "available", + "uri_template": template, + } + ], + }, + "citation": f"policy.json@{DIGEST}", + "sha256": DIGEST, + "path": "policy.json", + "preconditions": (), + } + + def package_builder( + *, + required: bool = True, + observed: str = "1.2.3", + ) -> tuple[kr.Builder, str, str]: + """Build a package and one version with stable fixture evidence.""" + builder = kr.Builder() + component = builder.add_component( + kind="library", + ecosystem="pypi", + name="app", + purl="pkg:pypi/app", + official_channel_required=required, + ) + version = builder.add_version( + component, resolved_version=observed, evidence=("input.json",) + ) + return builder, component, version + + +EXPECTED: dict[str, str] = { + "snapshot-mismatched-and-failed": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'zero-new-versions': {'pass': True, 'versions': 1, 'new_version_ids': [], 'removed_version_ids': []}, + 'slots-unchanged': {'pass': True, 'required_slots': 16, 'required_slots_baseline': 16, 'accepted_slots': 1, 'accepted_slots_baseline': 1}, + 'receipts-verify': {'pass': True, 'rows': 3, 'rejected': [], 'cas_errors': []}, + 'receipt-channel-binding': {'pass': False, + 'violations': ['input.jsonl:1: chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs canonical_uri mismatch', + 'input.jsonl:2: chn:other is not accepted-available']}, + 'snapshot-arithmetic': {'pass': True, + 'baseline_immutable_verified_channels': 0, + 'merged_immutable_verified_channels': 0, + 'credited_channels': 0, + 'expected_channels': 0, + 'already_satisfied_channels': 0, + 'unbindable_channels': 0, + 'unbindable_channel_ids': [], + 'unexplained_credit': [], + 'uncredited_expected': []}, + 'snapshot-channel-validity': {'pass': True, 'violations': []}, + 'added-snapshots-trace': {'pass': True, 'added_snapshots': 0, 'violations': []}, + 'no-silent-drop': {'pass': False, + 'dropped_verified_channels': [], + 'dropped_failure_channels': ['chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs']}}}""", + "wave-unaccepted-bad-bindings": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'required-slots': {'pass': True, + 'baseline': 16, + 'merged': 16, + 'expected': 16, + 'reclassified_components': 0, + 'reclassified_component_ids': [], + 'unexplained_flag_changes': []}, + 'accepted-slots': {'pass': False, + 'baseline': 1, + 'merged': 0, + 'delta': -1, + 'expected_delta': 16, + 'policy_stamped_components': 1, + 'baseline_policy_stamped_components': 0, + 'wave_policy_stamped_components': 1, + 'reclassified_accepted_slots': 0, + 'expected_matched': None}, + 'gap-arithmetic': {'pass': True, + 'baseline_official_channel_unresolved': 0, + 'merged_official_channel_unresolved': 0, + 'components_gained_available_channel': 0, + 'reclassified_components': 0}, + 'available-implies-accepted': {'pass': False, 'violations': ['chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs']}, + 'policy-bindings': {'pass': False, + 'violations': ['cmp-d25fa9e80d6b87b69c53aed9: ' + 'channel-policy:fixture-policy@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', + 'cmp-d25fa9e80d6b87b69c53aed9: ' + 'policy.json@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', + 'cmp-d25fa9e80d6b87b69c53aed9: ' + 'policy.json@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb']}}}""", + "test_bind_channel_snapshot_receipts.1": r"""({'receipts_dir': '/__fixture_root__', 'receipt_rows': 2, 'receipt_rows_rejected': 0, 'rejected_receipts': [], 'channels_receipted': 2, 'channels_bound': 1, 'bound_channel_ids_digest': 'sha256:4432f7747c85b594f5d8ebb8a04ac6a5e41984b935bd80e0a04036be0862cb50', 'channels_unbound': [{'channel_id': 'chn:other', 'reason': 'input.jsonl:2: receipt does not match a derived available channel'}]}, + [('cmp-d25fa9e80d6b87b69c53aed9', + {'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [{'component_version_id': 'ver-30de7421b28e93364d3ed079', 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'purl': None, 'constraint': None, 'resolved_version': '1.2.3', 'source_ref': None, 'artifact_digest': None, 'platform': None, 'build_metadata': {}, 'release_time': None, 'observed_at': '2026-01-02T03:04:05Z', 'valid_from': None, 'valid_to': None, 'resolution_state': 'resolved', 'evidence': ['input.json']}], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['input.json', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'available', + 'canonical_uri': 'https://example.org/app', + 'version_strategy': 'per-version', + 'gap': None}], + 'snapshots': [{'snapshot_id': 'snap:chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs:05a3c373de52', + 'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_version_id': 'ver-30de7421b28e93364d3ed079', + 'resolved_uri': 'https://example.org/app', + 'upstream_ref': None, + 'fetched_at': '2026-01-02T03:04:05Z', + 'observed_at': '2026-01-02T03:04:05Z', + 'etag': None, + 'last_modified': None, + 'content_hash': 'sha256:05a3c373de526a514e6548109ca53980136d5577709e7d76e925243c34e30f05', + 'media_type': None, + 'language': None, + 'coordinates': {}, + 'status': 'verified', + 'supersedes': [], + 'error_state': None}], + 'gaps': []})])""", + "test_bind_channel_snapshot_receipts_conflict.1": r"""({'receipts_dir': '/__fixture_root__', 'receipt_rows': 3, 'receipt_rows_rejected': 0, 'rejected_receipts': [], 'channels_receipted': 1, 'channels_bound': 0, 'bound_channel_ids_digest': 'sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945', 'channels_unbound': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', 'reason': 'conflicting receipts for one channel'}]}, + [('cmp-d25fa9e80d6b87b69c53aed9', + {'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['input.json', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'available', + 'canonical_uri': 'https://example.org/app', + 'version_strategy': 'per-version', + 'gap': None}], + 'snapshots': [], + 'gaps': []})])""", + "test_bind_channel_snapshot_receipts_rejects_uri_mismatch.1": r"""({'receipts_dir': '/__fixture_root__', 'receipt_rows': 1, 'receipt_rows_rejected': 0, 'rejected_receipts': [], 'channels_receipted': 1, 'channels_bound': 0, 'bound_channel_ids_digest': 'sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945', 'channels_unbound': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', 'reason': 'input.jsonl:1: receipt canonical_uri does not match the channel'}]}, + [('cmp-d25fa9e80d6b87b69c53aed9', + {'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['input.json', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'available', + 'canonical_uri': 'https://example.org/app', + 'version_strategy': 'per-version', + 'gap': None}], + 'snapshots': [], + 'gaps': []})])""", + "derive-empty": "([], [], {'record_kind': 'channel_policy_derivation_summary', 'baseline_manifest_id': 'mft-fce475094eadc4363ae774df9c8867d690376c40cbee429786017b1a7560738e', 'policies': [], 'components_considered': 0, 'records_emitted': 0, 'expected_accepted_slots_delta': 0, 'skipped': {}})", + "derive-no-policy": "([], [], {'record_kind': 'channel_policy_derivation_summary', 'baseline_manifest_id': 'mft-7e5f45218e6a9ac8f1504b280eb7b21db470d8ede7f0e5a79a8f921db4f1a16b', 'policies': [], 'components_considered': 1, 'records_emitted': 0, 'expected_accepted_slots_delta': 0, 'skipped': {'no-policy': 1}})", + "derive-not-required": r"""([], [('sample-pypi.json', {'record_kind': 'channel_policy_sample_audit', 'policy_record_id': 'fixture-policy', 'policy_sha256': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'policy_path': 'policy.json', 'sample_size': 0, 'total_matched': 0, 'entries': []})], + {'record_kind': 'channel_policy_derivation_summary', 'baseline_manifest_id': 'mft-d8b890fff3c75ad5f7405c558935f120895b5cb74d53dd912273b9d14331ce22', 'policies': [{'record_id': 'fixture-policy', 'path': 'policy.json', 'sha256': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ecosystem': 'pypi', 'matched': 0, 'expected_accepted_slots_delta': 0, 'sample_artifact': 'sample-pypi.json', 'sample_component_ids': []}], 'components_considered': 1, 'records_emitted': 0, 'expected_accepted_slots_delta': 0, 'skipped': {'not-required': 1}})""", + "derive-matching": r"""([('cmp-d25fa9e80d6b87b69c53aed9', + {'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:mft-2145f05f3522aada3fade0689b75ad7a0d1304dbbb383296376b210cc4b623dc', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['input.json', 'live-export:widgets.json#/a', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'available', + 'canonical_uri': 'live-export:widgets.json', + 'version_strategy': 'per-version', + 'gap': None}], + 'snapshots': [], + 'gaps': []})], + [('sample-pypi.json', {'record_kind': 'channel_policy_sample_audit', 'policy_record_id': 'fixture-policy', 'policy_sha256': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'policy_path': 'policy.json', 'sample_size': 1, 'total_matched': 1, 'entries': [{'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'name': 'app', 'purl': 'pkg:pypi/app', 'channels': [{'channel_type': 'docs', 'availability_state': 'available', 'canonical_uri': 'live-export:widgets.json'}]}]})], + {'record_kind': 'channel_policy_derivation_summary', 'baseline_manifest_id': 'mft-2145f05f3522aada3fade0689b75ad7a0d1304dbbb383296376b210cc4b623dc', 'policies': [{'record_id': 'fixture-policy', 'path': 'policy.json', 'sha256': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ecosystem': 'pypi', 'matched': 1, 'expected_accepted_slots_delta': 16, 'sample_artifact': 'sample-pypi.json', 'sample_component_ids': ['cmp-d25fa9e80d6b87b69c53aed9']}], 'components_considered': 1, 'records_emitted': 1, 'expected_accepted_slots_delta': 16, 'skipped': {}})""", + "wave-invalid": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': False, + 'errors': ['$schema does not match the canonical v2 envelope', 'authority_boundary does not match the canonical v2 envelope', 'authority_boundary must remain unreviewed and deny admission, release, and mutation', 'bounds does not match the canonical v2 envelope', 'completeness does not match the canonical v2 envelope', 'components must be an array', 'counts must equal {"components":0,"dependency_edges":0,"gaps":0,"occurrences":0,"sources":0,"versions":0}', 'dependency_edges must be an array', 'gaps must be an array', + 'generation_state must equal candidate', 'generator does not match the canonical v2 envelope', 'generator must be an object', 'input_set does not match the canonical v2 envelope', 'input_set must be an object', 'integrity does not match the canonical v2 envelope', 'manifest_id does not match the canonical v2 envelope', 'manifest_version must equal 2', 'occurrences must be an array', 'reconciliation does not match the canonical v2 envelope', 'record_kind must equal generated_discovery_manifest']}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'required-slots': {'pass': True, 'baseline': 0, 'merged': 0, 'expected': 0, 'reclassified_components': 0, 'reclassified_component_ids': [], 'unexplained_flag_changes': []}, + 'accepted-slots': {'pass': True, 'baseline': 0, 'merged': 0, 'delta': 0, 'expected_delta': 0, 'policy_stamped_components': 0, 'baseline_policy_stamped_components': 0, 'wave_policy_stamped_components': 0, 'reclassified_accepted_slots': 0, 'expected_matched': None}, + 'gap-arithmetic': {'pass': True, 'baseline_official_channel_unresolved': 0, 'merged_official_channel_unresolved': 0, 'components_gained_available_channel': 0, 'reclassified_components': 0}, + 'available-implies-accepted': {'pass': True, 'violations': []}, + 'policy-bindings': {'pass': True, 'violations': []}}}""", + "snapshot-invalid": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': False, + 'errors': ['$schema does not match the canonical v2 envelope', 'authority_boundary does not match the canonical v2 envelope', 'authority_boundary must remain unreviewed and deny admission, release, and mutation', 'bounds does not match the canonical v2 envelope', 'completeness does not match the canonical v2 envelope', 'components must be an array', 'counts must equal {"components":0,"dependency_edges":0,"gaps":0,"occurrences":0,"sources":0,"versions":0}', 'dependency_edges must be an array', 'gaps must be an array', + 'generation_state must equal candidate', 'generator does not match the canonical v2 envelope', 'generator must be an object', 'input_set does not match the canonical v2 envelope', 'input_set must be an object', 'integrity does not match the canonical v2 envelope', 'manifest_id does not match the canonical v2 envelope', 'manifest_version must equal 2', 'occurrences must be an array', 'reconciliation does not match the canonical v2 envelope', 'record_kind must equal generated_discovery_manifest']}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'zero-new-versions': {'pass': True, 'versions': 0, 'new_version_ids': [], 'removed_version_ids': []}, + 'slots-unchanged': {'pass': True, 'required_slots': 0, 'required_slots_baseline': 0, 'accepted_slots': 0, 'accepted_slots_baseline': 0}, + 'receipts-verify': {'pass': True, 'rows': 0, 'rejected': [], 'cas_errors': []}, + 'receipt-channel-binding': {'pass': True, 'violations': []}, + 'snapshot-arithmetic': {'pass': True, 'baseline_immutable_verified_channels': 0, 'merged_immutable_verified_channels': 0, 'credited_channels': 0, 'expected_channels': 0, 'already_satisfied_channels': 0, 'unbindable_channels': 0, 'unbindable_channel_ids': [], 'unexplained_credit': [], 'uncredited_expected': []}, + 'snapshot-channel-validity': {'pass': True, 'violations': []}, + 'added-snapshots-trace': {'pass': True, 'added_snapshots': 0, 'violations': []}, + 'no-silent-drop': {'pass': True, 'dropped_verified_channels': [], 'dropped_failure_channels': []}}}""", + "test_channel_snapshot_gate.1": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'zero-new-versions': {'pass': True, 'versions': 1, 'new_version_ids': [], 'removed_version_ids': []}, + 'slots-unchanged': {'pass': True, 'required_slots': 16, 'required_slots_baseline': 16, 'accepted_slots': 1, 'accepted_slots_baseline': 1}, + 'receipts-verify': {'pass': True, 'rows': 1, 'rejected': [], 'cas_errors': []}, + 'receipt-channel-binding': {'pass': True, 'violations': []}, + 'snapshot-arithmetic': {'pass': False, 'baseline_immutable_verified_channels': 0, 'merged_immutable_verified_channels': 0, 'credited_channels': 0, 'expected_channels': 1, 'already_satisfied_channels': 0, 'unbindable_channels': 0, 'unbindable_channel_ids': [], 'unexplained_credit': [], 'uncredited_expected': ['chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs']}, + 'snapshot-channel-validity': {'pass': True, 'violations': []}, + 'added-snapshots-trace': {'pass': True, 'added_snapshots': 0, 'violations': []}, + 'no-silent-drop': {'pass': False, 'dropped_verified_channels': ['chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs'], 'dropped_failure_channels': []}}}""", + "test_channel_snapshot_gate.2": r"""({'receipts_dir': '/__fixture_root__', 'receipt_rows': 1, 'receipt_rows_rejected': 0, 'rejected_receipts': [], 'channels_receipted': 1, 'channels_bound': 1, 'bound_channel_ids_digest': 'sha256:4432f7747c85b594f5d8ebb8a04ac6a5e41984b935bd80e0a04036be0862cb50', 'channels_unbound': []}, + [('cmp-d25fa9e80d6b87b69c53aed9', + {'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [{'component_version_id': 'ver-30de7421b28e93364d3ed079', 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'purl': None, 'constraint': None, 'resolved_version': '1.2.3', 'source_ref': None, 'artifact_digest': None, 'platform': None, 'build_metadata': {}, 'release_time': None, 'observed_at': '2026-01-02T03:04:05Z', 'valid_from': None, 'valid_to': None, 'resolution_state': 'resolved', 'evidence': ['input.json']}], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['input.json', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'available', + 'canonical_uri': 'https://example.org/app', + 'version_strategy': 'per-version', + 'gap': None}], + 'snapshots': [{'snapshot_id': 'snap:chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs:05a3c373de52', + 'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_version_id': 'ver-30de7421b28e93364d3ed079', + 'resolved_uri': 'https://example.org/app', + 'upstream_ref': None, + 'fetched_at': '2026-01-02T03:04:05Z', + 'observed_at': '2026-01-02T03:04:05Z', + 'etag': None, + 'last_modified': None, + 'content_hash': 'sha256:05a3c373de526a514e6548109ca53980136d5577709e7d76e925243c34e30f05', + 'media_type': None, + 'language': None, + 'coordinates': {}, + 'status': 'verified', + 'supersedes': [], + 'error_state': None}], + 'gaps': []})])""", + "test_channel_snapshot_gate.3": r"""{'pass': True, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'zero-new-versions': {'pass': True, 'versions': 1, 'new_version_ids': [], 'removed_version_ids': []}, + 'slots-unchanged': {'pass': True, 'required_slots': 16, 'required_slots_baseline': 16, 'accepted_slots': 1, 'accepted_slots_baseline': 1}, + 'receipts-verify': {'pass': True, 'rows': 1, 'rejected': [], 'cas_errors': []}, + 'receipt-channel-binding': {'pass': True, 'violations': []}, + 'snapshot-arithmetic': {'pass': True, 'baseline_immutable_verified_channels': 0, 'merged_immutable_verified_channels': 1, 'credited_channels': 1, 'expected_channels': 1, 'already_satisfied_channels': 0, 'unbindable_channels': 0, 'unbindable_channel_ids': [], 'unexplained_credit': [], 'uncredited_expected': []}, + 'snapshot-channel-validity': {'pass': True, 'violations': []}, + 'added-snapshots-trace': {'pass': True, 'added_snapshots': 1, 'violations': []}, + 'no-silent-drop': {'pass': True, 'dropped_verified_channels': [], 'dropped_failure_channels': []}}}""", + "test_channel_snapshot_gate.4": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'zero-new-versions': {'pass': False, 'versions': 2, 'new_version_ids': ['ver-932a9ce54053fd475f9927cb'], 'removed_version_ids': []}, + 'slots-unchanged': {'pass': True, 'required_slots': 16, 'required_slots_baseline': 16, 'accepted_slots': 1, 'accepted_slots_baseline': 1}, + 'receipts-verify': {'pass': True, 'rows': 1, 'rejected': [], 'cas_errors': []}, + 'receipt-channel-binding': {'pass': True, 'violations': []}, + 'snapshot-arithmetic': {'pass': True, 'baseline_immutable_verified_channels': 0, 'merged_immutable_verified_channels': 1, 'credited_channels': 1, 'expected_channels': 1, 'already_satisfied_channels': 0, 'unbindable_channels': 0, 'unbindable_channel_ids': [], 'unexplained_credit': [], 'uncredited_expected': []}, + 'snapshot-channel-validity': {'pass': True, 'violations': []}, + 'added-snapshots-trace': {'pass': True, 'added_snapshots': 1, 'violations': []}, + 'no-silent-drop': {'pass': True, 'dropped_verified_channels': [], 'dropped_failure_channels': []}}}""", + "test_channel_snapshot_gate_detects_corrupt_cas.1": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'zero-new-versions': {'pass': True, 'versions': 1, 'new_version_ids': [], 'removed_version_ids': []}, + 'slots-unchanged': {'pass': True, 'required_slots': 16, 'required_slots_baseline': 16, 'accepted_slots': 1, 'accepted_slots_baseline': 1}, + 'receipts-verify': {'pass': False, 'rows': 1, 'rejected': [], 'cas_errors': ['input.jsonl:1: CAS artifact hash does not match the receipt content_hash']}, + 'receipt-channel-binding': {'pass': True, 'violations': []}, + 'snapshot-arithmetic': {'pass': False, 'baseline_immutable_verified_channels': 0, 'merged_immutable_verified_channels': 0, 'credited_channels': 0, 'expected_channels': 1, 'already_satisfied_channels': 0, 'unbindable_channels': 0, 'unbindable_channel_ids': [], 'unexplained_credit': [], 'uncredited_expected': ['chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs']}, + 'snapshot-channel-validity': {'pass': True, 'violations': []}, + 'added-snapshots-trace': {'pass': True, 'added_snapshots': 0, 'violations': []}, + 'no-silent-drop': {'pass': False, 'dropped_verified_channels': ['chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs'], 'dropped_failure_channels': []}}}""", + "snapshot-cas-corrupt": r"""({'receipts_dir': '/__fixture_root__', 'receipt_rows': 1, 'receipt_rows_rejected': 0, 'rejected_receipts': [], 'channels_receipted': 1, 'channels_bound': 0, 'bound_channel_ids_digest': 'sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945', 'channels_unbound': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', 'reason': 'input.jsonl:1: CAS artifact hash does not match the receipt content_hash'}]}, + [('cmp-d25fa9e80d6b87b69c53aed9', + {'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['input.json', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'available', + 'canonical_uri': 'https://example.org/app', + 'version_strategy': 'per-version', + 'gap': None}], + 'snapshots': [], + 'gaps': []})])""", + "snapshot-no-receipts": "({'receipts_dir': '/__fixture_root__', 'receipt_rows': 0, 'receipt_rows_rejected': 0, 'rejected_receipts': [], 'channels_receipted': 0, 'channels_bound': 0, 'bound_channel_ids_digest': 'sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945', 'channels_unbound': []}, [])", + "snapshot-no-bindable": r"""({'receipts_dir': '/__fixture_root__', 'receipt_rows': 1, 'receipt_rows_rejected': 0, 'rejected_receipts': [], 'channels_receipted': 1, 'channels_bound': 0, 'bound_channel_ids_digest': 'sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945', 'channels_unbound': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', 'reason': 'no baseline version is expressible as a reviewed version'}]}, + [('cmp-d25fa9e80d6b87b69c53aed9', + {'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['input.json', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'available', + 'canonical_uri': 'https://example.org/app', + 'version_strategy': 'per-version', + 'gap': None}], + 'snapshots': [], + 'gaps': []})])""", + "test_channel_wave_gate.1": r"""{'pass': True, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'required-slots': {'pass': True, 'baseline': 16, 'merged': 16, 'expected': 16, 'reclassified_components': 0, 'reclassified_component_ids': [], 'unexplained_flag_changes': []}, + 'accepted-slots': {'pass': True, 'baseline': 0, 'merged': 0, 'delta': 0, 'expected_delta': 0, 'policy_stamped_components': 0, 'baseline_policy_stamped_components': 0, 'wave_policy_stamped_components': 0, 'reclassified_accepted_slots': 0, 'expected_matched': 0}, + 'gap-arithmetic': {'pass': True, 'baseline_official_channel_unresolved': 1, 'merged_official_channel_unresolved': 1, 'components_gained_available_channel': 0, 'reclassified_components': 0}, + 'available-implies-accepted': {'pass': True, 'violations': []}, + 'policy-bindings': {'pass': True, 'violations': []}}}""", + "test_channel_wave_gate.2": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'required-slots': {'pass': True, 'baseline': 16, 'merged': 16, 'expected': 16, 'reclassified_components': 0, 'reclassified_component_ids': [], 'unexplained_flag_changes': []}, + 'accepted-slots': {'pass': False, 'baseline': 0, 'merged': 0, 'delta': 0, 'expected_delta': 0, 'policy_stamped_components': 0, 'baseline_policy_stamped_components': 0, 'wave_policy_stamped_components': 0, 'reclassified_accepted_slots': 0, 'expected_matched': 1}, + 'gap-arithmetic': {'pass': True, 'baseline_official_channel_unresolved': 1, 'merged_official_channel_unresolved': 1, 'components_gained_available_channel': 0, 'reclassified_components': 0}, + 'available-implies-accepted': {'pass': True, 'violations': []}, + 'policy-bindings': {'pass': True, 'violations': []}}}""", + "test_channel_wave_gate.3": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'zero-new-components': {'pass': False, 'new_component_ids': [], 'removed_component_ids': ['cmp-d25fa9e80d6b87b69c53aed9']}, + 'required-slots': {'pass': False, 'baseline': 16, 'merged': 0, 'expected': 16, 'reclassified_components': 0, 'reclassified_component_ids': [], 'unexplained_flag_changes': []}, + 'accepted-slots': {'pass': True, 'baseline': 0, 'merged': 0, 'delta': 0, 'expected_delta': 0, 'policy_stamped_components': 0, 'baseline_policy_stamped_components': 0, 'wave_policy_stamped_components': 0, 'reclassified_accepted_slots': 0, 'expected_matched': 0}, + 'gap-arithmetic': {'pass': False, 'baseline_official_channel_unresolved': 1, 'merged_official_channel_unresolved': 0, 'components_gained_available_channel': 0, 'reclassified_components': 0}, + 'available-implies-accepted': {'pass': True, 'violations': []}, + 'policy-bindings': {'pass': True, 'violations': []}}}""", + "test_channel_wave_gate.4": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'zero-new-components': {'pass': False, 'new_component_ids': ['cmp-6a8a2cf681f7297195a653fc'], 'removed_component_ids': []}, + 'required-slots': {'pass': True, 'baseline': 16, 'merged': 16, 'expected': 16, 'reclassified_components': 0, 'reclassified_component_ids': [], 'unexplained_flag_changes': []}, + 'accepted-slots': {'pass': True, 'baseline': 0, 'merged': 0, 'delta': 0, 'expected_delta': 0, 'policy_stamped_components': 0, 'baseline_policy_stamped_components': 0, 'wave_policy_stamped_components': 0, 'reclassified_accepted_slots': 0, 'expected_matched': 0}, + 'gap-arithmetic': {'pass': True, 'baseline_official_channel_unresolved': 1, 'merged_official_channel_unresolved': 1, 'components_gained_available_channel': 0, 'reclassified_components': 0}, + 'available-implies-accepted': {'pass': True, 'violations': []}, + 'policy-bindings': {'pass': True, 'violations': []}}}""", + "test_derive_channel_records.1": r"""([], [('sample-pypi.json', {'record_kind': 'channel_policy_sample_audit', 'policy_record_id': 'fixture-policy', 'policy_sha256': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'policy_path': 'policy.json', 'sample_size': 0, 'total_matched': 0, 'entries': []})], + {'record_kind': 'channel_policy_derivation_summary', 'baseline_manifest_id': 'mft-8e230c2c9cafcb86c71f0b541cdf3703b89701ee5ecf61d14ef771d25f283cfb', 'policies': [{'record_id': 'fixture-policy', 'path': 'policy.json', 'sha256': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ecosystem': 'pypi', 'matched': 0, 'expected_accepted_slots_delta': 0, 'sample_artifact': 'sample-pypi.json', 'sample_component_ids': []}], 'components_considered': 1, 'records_emitted': 0, 'expected_accepted_slots_delta': 0, 'skipped': {'already-closed': 1}})""", + "test_derive_channel_records.2": r"""([('cmp-d25fa9e80d6b87b69c53aed9', + {'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:mft-7e5f45218e6a9ac8f1504b280eb7b21db470d8ede7f0e5a79a8f921db4f1a16b', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['input.json', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'available', + 'canonical_uri': 'https://example.org/app', + 'version_strategy': 'per-version', + 'gap': None}], + 'snapshots': [], + 'gaps': []})], + [('sample-pypi.json', {'record_kind': 'channel_policy_sample_audit', 'policy_record_id': 'fixture-policy', 'policy_sha256': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'policy_path': 'policy.json', 'sample_size': 1, 'total_matched': 1, 'entries': [{'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'name': 'app', 'purl': 'pkg:pypi/app', 'channels': [{'channel_type': 'docs', 'availability_state': 'available', 'canonical_uri': 'https://example.org/app'}]}]})], + {'record_kind': 'channel_policy_derivation_summary', 'baseline_manifest_id': 'mft-7e5f45218e6a9ac8f1504b280eb7b21db470d8ede7f0e5a79a8f921db4f1a16b', 'policies': [{'record_id': 'fixture-policy', 'path': 'policy.json', 'sha256': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ecosystem': 'pypi', 'matched': 1, 'expected_accepted_slots_delta': 16, 'sample_artifact': 'sample-pypi.json', 'sample_component_ids': ['cmp-d25fa9e80d6b87b69c53aed9']}], 'components_considered': 1, 'records_emitted': 1, 'expected_accepted_slots_delta': 16, 'skipped': {}})""", + "test_derive_channel_records.3": r"""([], [('sample-pypi.json', {'record_kind': 'channel_policy_sample_audit', 'policy_record_id': 'fixture-policy', 'policy_sha256': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'policy_path': 'policy.json', 'sample_size': 0, 'total_matched': 0, 'entries': []})], + {'record_kind': 'channel_policy_derivation_summary', 'baseline_manifest_id': 'mft-7e5f45218e6a9ac8f1504b280eb7b21db470d8ede7f0e5a79a8f921db4f1a16b', 'policies': [{'record_id': 'fixture-policy', 'path': 'policy.json', 'sha256': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'ecosystem': 'pypi', 'matched': 0, 'expected_accepted_slots_delta': 0, 'sample_artifact': 'sample-pypi.json', 'sample_component_ids': []}], 'components_considered': 1, 'records_emitted': 0, 'expected_accepted_slots_delta': 0, 'skipped': {'precondition-mismatch': 1}})""", + "test_derive_channel_records.4": r"""('RegistryInputError', + 'derive-channels baseline is invalid: $schema does not match the canonical v2 envelope; authority_boundary does not match the canonical v2 envelope; authority_boundary must remain unreviewed and deny admission, release, and mutation; bounds does not match the canonical v2 envelope; completeness does not match the canonical v2 envelope; components must be an array; counts must equal {"components":0,"dependency_edges":0,"gaps":0,"occurrences":0,"sources":0,"versions":0}; dependency_edges must be an array; gaps must be an array; generation_state must equal candidate; ' + 'generator does not match the canonical v2 envelope; generator must be an object; input_set does not match the canonical v2 envelope; input_set must be an object; integrity does not match the canonical v2 envelope; manifest_id does not match the canonical v2 envelope; manifest_version must equal 2; occurrences must be an array; reconciliation does not match the canonical v2 envelope; record_kind must equal generated_discovery_manifest')""", + "test_bind_gitops_identity.1": r"""({'$schema': 'https://json-schema.org/draft/2020-12/schema', + 'authority_boundary': {'review_state': 'unreviewed', 'authoritative': False, 'compile_eligible': False, 'promote_eligible': False, 'source_admission': False, 'retrieval_release': False, 'production_mutation': False}, + 'base_manifest_id': None, + 'components': [{'component_id': 'cmp-14e0ecfc9e990dbf5fb73775', 'ecosystem': 'git', 'kind': 'git-repository', 'lifecycles': ['repository-used'], 'metadata': {'self_repository': True}, 'name': 'self', 'namespace': '', 'official_channel_required': False, 'official_channels': []}], + 'dependency_edges': [], + 'gaps': [{'component_id': 'cmp-14e0ecfc9e990dbf5fb73775', 'component_version_id': 'ver-1dee7cb3d8731625f94ecbf3', 'evidence': ['input.json', 'sha256:72ffc047a71d84ec79551dab3dc1ad4c44c10c8d4385df7c22b9c66fb7741199'], 'gap_id': 'gap-0e03d5a360258807c3b7cc49', 'gap_type': 'gitops-self-reference-observed', 'message': "Self-repository GitOps ref 'main' deliberately tracks this repository at observed commit e3dfffb93b53a5fce9a50466315151c11fedc9f1"}], + 'generation_state': 'candidate', + 'generator': {'name': 'knowledge-registry', 'ruleset_hash': 'sha256:e49f3c59e9a4f697b953166bd42e04ef0cf1a9838299fc2fd7168dc4418aa909', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'source_ref': 'tools/knowledge-registry/knowledge_registry.py#sha256:932e46cc7a68437ad6cb5eba1c8609a78d800806d8a082771807c124b2bdb6bc', 'version': '2'}, + 'input_set': {'entries': [], 'required_source_classes': []}, + 'manifest_version': 2, + 'occurrences': [{'component_id': 'cmp-14e0ecfc9e990dbf5fb73775', 'component_version_id': 'ver-1dee7cb3d8731625f94ecbf3', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': '/receipts/input.jsonl:1', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-27065bf0d61cf256dbd9c96a', 'optional': False, 'raw_value': 'e3dfffb93b53a5fce9a50466315151c11fedc9f1', 'role': 'gitops-source-observation', 'source_id': 'src-7ec3bd847e8d52ce12f92c0f'}], + 'record_kind': 'generated_discovery_manifest', + 'schema_version': '2.0.0', + 'sources': [{'content_hash': 'sha256:72ffc047a71d84ec79551dab3dc1ad4c44c10c8d4385df7c22b9c66fb7741199', + 'evidence_uri': 'gitops-observation:sha256:72ffc047a71d84ec79551dab3dc1ad4c44c10c8d4385df7c22b9c66fb7741199', + 'metadata': {'evidence_class': 'repository', 'receipt': {'canonical_uri': 'https://git.example.org/example/app', 'cas_path': 'cas/72ffc047a71d84ec79551dab3dc1ad4c44c10c8d4385df7c22b9c66fb7741199', 'observed_at': '2026-01-02T03:04:05Z', 'runner_version': '', 'upstream_ref': 'e3dfffb93b53a5fce9a50466315151c11fedc9f1'}}, + 'source_id': 'src-7ec3bd847e8d52ce12f92c0f', + 'source_type': 'gitops-source-observation'}], + 'versions': [{'component_id': 'cmp-14e0ecfc9e990dbf5fb73775', + 'component_version_id': 'ver-1dee7cb3d8731625f94ecbf3', + 'evidence': ['input.json'], + 'metadata': {'gitops_source_observation': {'evidence_cas_path': 'cas/72ffc047a71d84ec79551dab3dc1ad4c44c10c8d4385df7c22b9c66fb7741199', 'evidence_content_hash': 'sha256:72ffc047a71d84ec79551dab3dc1ad4c44c10c8d4385df7c22b9c66fb7741199', 'observed_at': '2026-01-02T03:04:05Z', 'observed_commit': 'e3dfffb93b53a5fce9a50466315151c11fedc9f1', 'observed_ref': 'main', 'receipt_canonical_uri': 'https://git.example.org/example/app', 'resolver': 'git-commit-object-receipt'}}, + 'resolution_state': 'unresolved', + 'source_ref': 'main'}], + 'bounds': {'tracked_files': 20000, 'discovery_files': 10000, 'discovery_file_bytes': 8388608, 'discovery_total_bytes': 134217728, 'json_input_bytes': 805306368, 'json_depth': 128, 'json_nodes': 20000000, 'serialized_output_bytes': 805306368, 'sources': 100000, 'components': 100000, 'versions': 200000, 'occurrences': 400000, 'dependency_edges': 700000, 'gaps': 400000}, + 'counts': {'sources': 1, 'components': 1, 'versions': 1, 'occurrences': 1, 'dependency_edges': 0, 'gaps': 1}, + 'completeness': {'input': {'state': 'unknown', 'input_count': 0, 'blocking_input_ids': []}, 'enumeration': {'state': 'unknown'}, 'closure': {'state': 'unknown', 'blocking_gap_ids': []}, 'identity': {'state': 'complete', 'blocking_gap_ids': []}, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots': {'state': 'unknown', 'accepted_available_channels': 0, 'immutable_verified_channels': 0, 'missing_channel_ids': []}, 'all_axes_complete': False}, + 'reconciliation': {'previous_manifest_id': None, 'complete_mark': False, 'removal_allowed': False, 'added': [], 'changed': [], 'missing': [], 'removed': []}, + 'integrity': {'canonicalization': 'archeion-canonical-json-v1', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'deterministic_order': True, 'exact_counts': {'sources': 1, 'components': 1, 'versions': 1, 'occurrences': 1, 'dependency_edges': 0, 'gaps': 1}, 'manifest_hash': 'sha256:43889582ac4b64d360a0a2fefbd52524359ebb41a63fd1327abdb59c3ca7772b'}, + 'manifest_id': 'mft-43889582ac4b64d360a0a2fefbd52524359ebb41a63fd1327abdb59c3ca7772b'}, + {'record_kind': 'gitops_identity_binding_summary', + 'baseline_manifest_id': 'mft-2682b55a12b68257ba316a3ee9db824e48a6c1a769737fe25f42baf64de52ed4', + 'observed_ref': 'main', + 'receipts_dir': '/__fixture_root__', + 'receipts_verified': 1, + 'receipts_refused': 0, + 'refused_receipts': [], + 'commits': ['e3dfffb93b53a5fce9a50466315151c11fedc9f1'], + 'components_bound': 1, + 'versions_bound': 1, + 'bound_version_ids_digest': 'sha256:f6a3535dc6ca5d3ac78dab7479616eb4a6ae34224057b4a3fa0a1155fab4b988', + 'skipped': {'not-a-self-repository-component': 1}, + 'fragment_manifest_id': 'mft-43889582ac4b64d360a0a2fefbd52524359ebb41a63fd1327abdb59c3ca7772b'})""", + "test_bind_gitops_identity.2": "('RegistryInputError', \"--observed-ref 'e3dfffb93b53a5fce9a50466315151c11fedc9f1' is not a mutable ref\")", + "test_bind_oci_identity.1": r"""({'$schema': 'https://json-schema.org/draft/2020-12/schema', + 'authority_boundary': {'review_state': 'unreviewed', 'authoritative': False, 'compile_eligible': False, 'promote_eligible': False, 'source_admission': False, 'retrieval_release': False, 'production_mutation': False}, + 'base_manifest_id': None, + 'components': [{'component_id': 'cmp-e3a2012f0f8df626445ba38f', + 'ecosystem': 'oci', + 'kind': 'oci-image', + 'lifecycles': ['repository-used'], + 'metadata': {'oci_repository': 'registry.example.org/example/app'}, + 'name': 'app', + 'namespace': 'registry.example.org/example', + 'official_channel_required': True, + 'official_channels': [{'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-ad0da62272c2de3333729d74', 'channel_type': 'advisory', 'review_state': 'needs-review'}, {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-f02241319fa6113219eed50d', 'channel_type': 'api', 'review_state': 'needs-review'}, + {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-9a494e8be9de2e0cb1e569ba', 'channel_type': 'artifact', 'review_state': 'needs-review'}, {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-f91f1e1d2adfebd3c34f6246', 'channel_type': 'changelog', 'review_state': 'needs-review'}, + {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-d59ba1617dcf395f4a240fba', 'channel_type': 'config', 'review_state': 'needs-review'}, {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-36fd154b8aa5add9ce09bebb', 'channel_type': 'deprecation', 'review_state': 'needs-review'}, + {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-a622383815ecf47ae7ee1a44', 'channel_type': 'docs', 'review_state': 'needs-review'}, {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-a6e69fc2eabc3da75f65b34c', 'channel_type': 'license', 'review_state': 'needs-review'}, + {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-795e7caf35d1fd702ccee92a', 'channel_type': 'migration', 'review_state': 'needs-review'}, {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-423a924ca4392931e50e5577', 'channel_type': 'package', 'review_state': 'needs-review'}, + {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-c103d8f3e18f1e7b846b124a', 'channel_type': 'provenance', 'review_state': 'needs-review'}, {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-bb457539242b70d504591857', 'channel_type': 'reference', 'review_state': 'needs-review'}, + {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-49d36662d2737f58dbf980f9', 'channel_type': 'release', 'review_state': 'needs-review'}, {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-b2836709d69a700fa8444b91', 'channel_type': 'sbom', 'review_state': 'needs-review'}, + {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-99bc2ce5c67352c0ffdf914e', 'channel_type': 'schema', 'review_state': 'needs-review'}, {'authority_state': 'non-authoritative', 'availability_state': 'unresolved', 'channel_id': 'chn-29e00417fc32b43cfa9efea2', 'channel_type': 'source', 'review_state': 'needs-review'}], + 'purl': 'pkg:oci/app?repository_url=registry.example.org/example/app'}], + 'dependency_edges': [], + 'gaps': [{'component_id': 'cmp-e3a2012f0f8df626445ba38f', 'component_version_id': 'ver-860ce11e99543b91d2aec1a6', 'evidence': ['input.json#/image', 'sha256:e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a'], 'gap_id': 'gap-179ad5948ae29021f6fd71d3', 'gap_type': 'oci-artifact-version-observed', 'message': 'OCI artifact version is bound to the receipt-verified registry manifest sha256:e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a'}, + {'component_id': 'cmp-e3a2012f0f8df626445ba38f', 'evidence': [], 'gap_id': 'gap-9cf29ed78a2eea6b41401a72', 'gap_type': 'transitive-inventory-unavailable', 'message': 'No authoritative lockfile or SBOM exposes transitive packages for cmp-e3a2012f0f8df626445ba38f'}, {'component_id': 'cmp-e3a2012f0f8df626445ba38f', 'evidence': [], 'gap_id': 'gap-d2ae83510e5143436b95568d', 'gap_type': 'official-channel-unresolved', 'message': 'No reviewed official channel is registered for cmp-e3a2012f0f8df626445ba38f'}, + {'component_id': 'cmp-e3a2012f0f8df626445ba38f', 'component_version_id': 'ver-860ce11e99543b91d2aec1a6', 'evidence': ['input.json#/image', 'sha256:e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a'], 'gap_id': 'gap-df38f1e0569e553224f39c2d', 'gap_type': 'oci-platform-observed', 'message': 'OCI artifact platform linux/amd64 is bound to the receipt-verified registry image config'}], + 'generation_state': 'candidate', + 'generator': {'name': 'knowledge-registry', 'ruleset_hash': 'sha256:e49f3c59e9a4f697b953166bd42e04ef0cf1a9838299fc2fd7168dc4418aa909', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'source_ref': 'tools/knowledge-registry/knowledge_registry.py#sha256:932e46cc7a68437ad6cb5eba1c8609a78d800806d8a082771807c124b2bdb6bc', 'version': '2'}, + 'input_set': {'entries': [], 'required_source_classes': []}, + 'manifest_version': 2, + 'occurrences': [{'component_id': 'cmp-e3a2012f0f8df626445ba38f', 'component_version_id': 'ver-860ce11e99543b91d2aec1a6', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': '/receipts/input.jsonl:1', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-995f8358720fada88c27e03b', 'optional': False, 'raw_value': 'sha256:e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a', 'role': 'oci-artifact-observation', 'source_id': 'src-1248bd1500389ab27883b02a'}], + 'record_kind': 'generated_discovery_manifest', + 'schema_version': '2.0.0', + 'sources': [{'content_hash': 'sha256:e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a', + 'evidence_uri': 'oci-observation:sha256:e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a', + 'metadata': {'evidence_class': 'reference', 'receipt': {'canonical_uri': 'oci://registry.example.org/example/app:1.2.3', 'cas_path': 'cas/e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a', 'observed_at': '2026-01-02T03:04:06Z', 'runner_version': '', 'upstream_ref': 'sha256:e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a'}}, + 'source_id': 'src-1248bd1500389ab27883b02a', + 'source_type': 'oci-artifact-observation'}], + 'versions': [{'component_id': 'cmp-e3a2012f0f8df626445ba38f', + 'component_version_id': 'ver-860ce11e99543b91d2aec1a6', + 'evidence': ['input.json#/image'], + 'metadata': {'oci_artifact_observation': {'evidence_cas_path': 'cas/e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a', + 'evidence_content_hash': 'sha256:e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a', + 'manifest_kind': 'manifest', + 'manifest_media_type': 'application/vnd.oci.image.manifest.v1+json', + 'observed_at': '2026-01-02T03:04:06Z', + 'platform': 'linux/amd64', + 'platforms': ['linux/amd64'], + 'receipt_canonical_uri': 'oci://registry.example.org/example/app:1.2.3', + 'reference': '1.2.3', + 'reference_kind': 'tag', + 'registry': 'registry.example.org', + 'repository': 'example/app', + 'resolved_digest': 'sha256:e08f004de94b7ea0bf4838e17f856272e014d3ef5913a31b826a0b4d85b2b53a', + 'resolver': 'oci-registry-manifest'}}, + 'resolution_state': 'unresolved', + 'resolved_version': '1.2.3'}], + 'bounds': {'tracked_files': 20000, 'discovery_files': 10000, 'discovery_file_bytes': 8388608, 'discovery_total_bytes': 134217728, 'json_input_bytes': 805306368, 'json_depth': 128, 'json_nodes': 20000000, 'serialized_output_bytes': 805306368, 'sources': 100000, 'components': 100000, 'versions': 200000, 'occurrences': 400000, 'dependency_edges': 700000, 'gaps': 400000}, + 'counts': {'sources': 1, 'components': 1, 'versions': 1, 'occurrences': 1, 'dependency_edges': 0, 'gaps': 4}, + 'completeness': {'input': {'state': 'unknown', 'input_count': 0, 'blocking_input_ids': []}, 'enumeration': {'state': 'unknown'}, 'closure': {'state': 'gapped', 'blocking_gap_ids': ['gap-9cf29ed78a2eea6b41401a72']}, 'identity': {'state': 'complete', 'blocking_gap_ids': []}, 'channel_review': {'state': 'gapped', 'required_slots': 16, 'accepted_slots': 0}, 'snapshots': {'state': 'unknown', 'accepted_available_channels': 0, 'immutable_verified_channels': 0, 'missing_channel_ids': []}, 'all_axes_complete': False}, + 'reconciliation': {'previous_manifest_id': None, 'complete_mark': False, 'removal_allowed': False, 'added': [], 'changed': [], 'missing': [], 'removed': []}, + 'integrity': {'canonicalization': 'archeion-canonical-json-v1', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'deterministic_order': True, 'exact_counts': {'sources': 1, 'components': 1, 'versions': 1, 'occurrences': 1, 'dependency_edges': 0, 'gaps': 4}, 'manifest_hash': 'sha256:6a228c1b3140537b56086e366023e0c5da9867cdaf5010c3a9da0d3e6660dd6f'}, + 'manifest_id': 'mft-6a228c1b3140537b56086e366023e0c5da9867cdaf5010c3a9da0d3e6660dd6f'}, + {'record_kind': 'oci_identity_binding_summary', + 'baseline_manifest_id': 'mft-28a93fda3248b550960a3b3cd27aaee4d4be06af7bfb0bef02a627fe95426c7f', + 'receipts_dir': '/__fixture_root__', + 'receipts_verified': 1, + 'receipts_typed_failures': 0, + 'typed_failures': [], + 'receipts_refused': 0, + 'refused_receipts': [], + 'planned_refs': 1, + 'planned_refs_unreceipted': [], + 'planned_versions': 1, + 'unfetchable_version_ids': [], + 'components_bound': 1, + 'versions_bound': 1, + 'bound_version_ids_digest': 'sha256:4d37cd1bc45cecec00a7017d4f0e62cf095203d5914721ba121153f22d80707e', + 'skipped': {}, + 'fragment_manifest_id': 'mft-6a228c1b3140537b56086e366023e0c5da9867cdaf5010c3a9da0d3e6660dd6f'})""", + "test_bind_oci_identity.2": "('RegistryInputError', 'OCI receipts disagree on the identity of oci://registry.example.org/example/app:1.2.3: 2 distinct manifests across 2 receipts')", + "test_identity_gate.1": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'generation-anchored': {'pass': True, 'anchor_manifest_id': 'mft-d8b890fff3c75ad5f7405c558935f120895b5cb74d53dd912273b9d14331ce22', 'control_identity_blocking': 0, 'violations': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'version-delta-justified': {'pass': False, 'versions': 2, 'declared_new': 0, 'declared_removed': 0, 'undeclared_new_version_ids': ['ver-932a9ce54053fd475f9927cb'], 'undeclared_removed_version_ids': []}, + 'reviewed-version-generation': {'pass': True, 'stale_reviewed_version_ids': []}, + 'platform-multi-zero': {'pass': True, 'control': 0, 'treatment': 0}, + 'no-unknown-platform': {'pass': True, 'violations': []}, + 'gap-arithmetic-identity': {'pass': True, 'control_identity_blocking': 0, 'treatment_identity_blocking': 0, 'closed': 0, 'closed_by_gap_type': {}, 'expected_closed_by_gap_type': {}, 'explained_by': {}, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'non-blocking-types-declared': {'pass': True, 'new_gap_types': [], 'blocking_new_gap_types': [], 'declared_non_blocking_types': ['gitops-self-reference-observed', 'oci-artifact-version-observed', 'oci-platform-index', 'oci-platform-observed']}, + 'receipt-coverage': {'pass': True, 'receipts_verified': 0, 'receipts_refused': 0, 'refused_receipts': [], 'unused_receipt_hashes': [], 'oci_planned_refs': 0, 'oci_typed_failures': 0, 'oci_unreceipted_refs': [], 'oci_unused_receipt_refs': []}, + 'axis-isolation': {'pass': True, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots_immutable_verified_channels': 0, 'violations': []}, + 'deviations-ratified': {'pass': True, 'declarations': [], 'exempted_by_gap_type': {}, 'expected_exempted_by_gap_type': {}, 'violations': []}, + 'closure-delta-evidenced': {'pass': True, 'reference_closure_blocking': 0, 'treatment_closure_blocking': 0, 'closed_by_gap_type': {}, 'sbom_inventory_subjects': 0, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'bounds': {'pass': True, 'versions': 2, 'bound': 200000}}}""", + "test_identity_gate.2": r"""{'pass': True, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'generation-anchored': {'pass': True, 'anchor_manifest_id': 'mft-d8b890fff3c75ad5f7405c558935f120895b5cb74d53dd912273b9d14331ce22', 'control_identity_blocking': 0, 'violations': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'version-delta-justified': {'pass': True, 'versions': 2, 'declared_new': 1, 'declared_removed': 0, 'undeclared_new_version_ids': [], 'undeclared_removed_version_ids': []}, + 'reviewed-version-generation': {'pass': True, 'stale_reviewed_version_ids': []}, + 'platform-multi-zero': {'pass': True, 'control': 0, 'treatment': 0}, + 'no-unknown-platform': {'pass': True, 'violations': []}, + 'gap-arithmetic-identity': {'pass': True, 'control_identity_blocking': 0, 'treatment_identity_blocking': 0, 'closed': 0, 'closed_by_gap_type': {}, 'expected_closed_by_gap_type': {}, 'explained_by': {}, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'non-blocking-types-declared': {'pass': True, 'new_gap_types': [], 'blocking_new_gap_types': [], 'declared_non_blocking_types': ['gitops-self-reference-observed', 'oci-artifact-version-observed', 'oci-platform-index', 'oci-platform-observed']}, + 'receipt-coverage': {'pass': True, 'receipts_verified': 0, 'receipts_refused': 0, 'refused_receipts': [], 'unused_receipt_hashes': [], 'oci_planned_refs': 0, 'oci_typed_failures': 0, 'oci_unreceipted_refs': [], 'oci_unused_receipt_refs': []}, + 'axis-isolation': {'pass': True, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots_immutable_verified_channels': 0, 'violations': []}, + 'deviations-ratified': {'pass': True, 'declarations': [], 'exempted_by_gap_type': {}, 'expected_exempted_by_gap_type': {}, 'violations': []}, + 'closure-delta-evidenced': {'pass': True, 'reference_closure_blocking': 0, 'treatment_closure_blocking': 0, 'closed_by_gap_type': {}, 'sbom_inventory_subjects': 0, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'bounds': {'pass': True, 'versions': 2, 'bound': 200000}}}""", + "test_identity_gate.3": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'generation-anchored': {'pass': True, 'anchor_manifest_id': 'mft-d8b890fff3c75ad5f7405c558935f120895b5cb74d53dd912273b9d14331ce22', 'control_identity_blocking': 0, 'violations': []}, + 'zero-new-components': {'pass': False, 'new_component_ids': [], 'removed_component_ids': ['cmp-d25fa9e80d6b87b69c53aed9']}, + 'version-delta-justified': {'pass': False, 'versions': 0, 'declared_new': 0, 'declared_removed': 0, 'undeclared_new_version_ids': [], 'undeclared_removed_version_ids': ['ver-30de7421b28e93364d3ed079']}, + 'reviewed-version-generation': {'pass': True, 'stale_reviewed_version_ids': []}, + 'platform-multi-zero': {'pass': True, 'control': 0, 'treatment': 0}, + 'no-unknown-platform': {'pass': True, 'violations': []}, + 'gap-arithmetic-identity': {'pass': True, 'control_identity_blocking': 0, 'treatment_identity_blocking': 0, 'closed': 0, 'closed_by_gap_type': {}, 'expected_closed_by_gap_type': {}, 'explained_by': {}, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'non-blocking-types-declared': {'pass': True, 'new_gap_types': [], 'blocking_new_gap_types': [], 'declared_non_blocking_types': ['gitops-self-reference-observed', 'oci-artifact-version-observed', 'oci-platform-index', 'oci-platform-observed']}, + 'receipt-coverage': {'pass': True, 'receipts_verified': 0, 'receipts_refused': 0, 'refused_receipts': [], 'unused_receipt_hashes': [], 'oci_planned_refs': 0, 'oci_typed_failures': 0, 'oci_unreceipted_refs': [], 'oci_unused_receipt_refs': []}, + 'axis-isolation': {'pass': True, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots_immutable_verified_channels': 0, 'violations': []}, + 'deviations-ratified': {'pass': True, 'declarations': [], 'exempted_by_gap_type': {}, 'expected_exempted_by_gap_type': {}, 'violations': []}, + 'closure-delta-evidenced': {'pass': True, 'reference_closure_blocking': 0, 'treatment_closure_blocking': 0, 'closed_by_gap_type': {}, 'sbom_inventory_subjects': 0, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'bounds': {'pass': True, 'versions': 0, 'bound': 200000}}}""", + "test_identity_gate.4": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'generation-anchored': {'pass': False, 'anchor_manifest_id': 'mft-fce475094eadc4363ae774df9c8867d690376c40cbee429786017b1a7560738e', 'control_identity_blocking': 0, 'violations': ['control components differ from the anchor generation']}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'version-delta-justified': {'pass': True, 'versions': 2, 'declared_new': 1, 'declared_removed': 0, 'undeclared_new_version_ids': [], 'undeclared_removed_version_ids': []}, + 'reviewed-version-generation': {'pass': True, 'stale_reviewed_version_ids': []}, + 'platform-multi-zero': {'pass': True, 'control': 0, 'treatment': 0}, + 'no-unknown-platform': {'pass': True, 'violations': []}, + 'gap-arithmetic-identity': {'pass': True, 'control_identity_blocking': 0, 'treatment_identity_blocking': 0, 'closed': 0, 'closed_by_gap_type': {}, 'expected_closed_by_gap_type': {}, 'explained_by': {}, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'non-blocking-types-declared': {'pass': True, 'new_gap_types': [], 'blocking_new_gap_types': [], 'declared_non_blocking_types': ['gitops-self-reference-observed', 'oci-artifact-version-observed', 'oci-platform-index', 'oci-platform-observed']}, + 'receipt-coverage': {'pass': True, 'receipts_verified': 0, 'receipts_refused': 0, 'refused_receipts': [], 'unused_receipt_hashes': [], 'oci_planned_refs': 0, 'oci_typed_failures': 0, 'oci_unreceipted_refs': [], 'oci_unused_receipt_refs': []}, + 'axis-isolation': {'pass': True, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots_immutable_verified_channels': 0, 'violations': []}, + 'deviations-ratified': {'pass': True, 'declarations': [], 'exempted_by_gap_type': {}, 'expected_exempted_by_gap_type': {}, 'violations': []}, + 'closure-delta-evidenced': {'pass': True, 'reference_closure_blocking': 0, 'treatment_closure_blocking': 0, 'closed_by_gap_type': {}, 'sbom_inventory_subjects': 0, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'bounds': {'pass': True, 'versions': 2, 'bound': 200000}}}""", + "identity-empty": r"""{'pass': True, + 'checks': {'merged-valid': {'pass': True, 'errors': []}, + 'generation-anchored': {'pass': True, 'anchor_manifest_id': None, 'control_identity_blocking': 0, 'violations': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'version-delta-justified': {'pass': True, 'versions': 0, 'declared_new': 0, 'declared_removed': 0, 'undeclared_new_version_ids': [], 'undeclared_removed_version_ids': []}, + 'reviewed-version-generation': {'pass': True, 'stale_reviewed_version_ids': []}, + 'platform-multi-zero': {'pass': True, 'control': 0, 'treatment': 0}, + 'no-unknown-platform': {'pass': True, 'violations': []}, + 'gap-arithmetic-identity': {'pass': True, 'control_identity_blocking': 0, 'treatment_identity_blocking': 0, 'closed': 0, 'closed_by_gap_type': {}, 'expected_closed_by_gap_type': {}, 'explained_by': {}, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'non-blocking-types-declared': {'pass': True, 'new_gap_types': [], 'blocking_new_gap_types': [], 'declared_non_blocking_types': ['gitops-self-reference-observed', 'oci-artifact-version-observed', 'oci-platform-index', 'oci-platform-observed']}, + 'receipt-coverage': {'pass': True, 'receipts_verified': 0, 'receipts_refused': 0, 'refused_receipts': [], 'unused_receipt_hashes': [], 'oci_planned_refs': 0, 'oci_typed_failures': 0, 'oci_unreceipted_refs': [], 'oci_unused_receipt_refs': []}, + 'axis-isolation': {'pass': True, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots_immutable_verified_channels': 0, 'violations': []}, + 'deviations-ratified': {'pass': True, 'declarations': [], 'exempted_by_gap_type': {}, 'expected_exempted_by_gap_type': {}, 'violations': []}, + 'closure-delta-evidenced': {'pass': True, 'reference_closure_blocking': 0, 'treatment_closure_blocking': 0, 'closed_by_gap_type': {}, 'sbom_inventory_subjects': 0, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'bounds': {'pass': True, 'versions': 0, 'bound': 200000}}}""", + "identity-invalid": r"""{'pass': False, + 'checks': {'merged-valid': {'pass': False, + 'errors': ['$schema does not match the canonical v2 envelope', 'authority_boundary does not match the canonical v2 envelope', 'authority_boundary must remain unreviewed and deny admission, release, and mutation', 'bounds does not match the canonical v2 envelope', 'completeness does not match the canonical v2 envelope', 'components must be an array', 'counts must equal {"components":0,"dependency_edges":0,"gaps":0,"occurrences":0,"sources":0,"versions":0}', 'dependency_edges must be an array', 'gaps must be an array', + 'generation_state must equal candidate', 'generator does not match the canonical v2 envelope', 'generator must be an object', 'input_set does not match the canonical v2 envelope', 'input_set must be an object', 'integrity does not match the canonical v2 envelope', 'manifest_id does not match the canonical v2 envelope', 'manifest_version must equal 2', 'occurrences must be an array', 'reconciliation does not match the canonical v2 envelope', 'record_kind must equal generated_discovery_manifest']}, + 'generation-anchored': {'pass': True, 'anchor_manifest_id': None, 'control_identity_blocking': 0, 'violations': []}, + 'zero-new-components': {'pass': True, 'new_component_ids': [], 'removed_component_ids': []}, + 'version-delta-justified': {'pass': True, 'versions': 0, 'declared_new': 0, 'declared_removed': 0, 'undeclared_new_version_ids': [], 'undeclared_removed_version_ids': []}, + 'reviewed-version-generation': {'pass': True, 'stale_reviewed_version_ids': []}, + 'platform-multi-zero': {'pass': True, 'control': 0, 'treatment': 0}, + 'no-unknown-platform': {'pass': True, 'violations': []}, + 'gap-arithmetic-identity': {'pass': True, 'control_identity_blocking': 0, 'treatment_identity_blocking': 0, 'closed': 0, 'closed_by_gap_type': {}, 'expected_closed_by_gap_type': {}, 'explained_by': {}, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'non-blocking-types-declared': {'pass': True, 'new_gap_types': [], 'blocking_new_gap_types': [], 'declared_non_blocking_types': ['gitops-self-reference-observed', 'oci-artifact-version-observed', 'oci-platform-index', 'oci-platform-observed']}, + 'receipt-coverage': {'pass': True, 'receipts_verified': 0, 'receipts_refused': 0, 'refused_receipts': [], 'unused_receipt_hashes': [], 'oci_planned_refs': 0, 'oci_typed_failures': 0, 'oci_unreceipted_refs': [], 'oci_unused_receipt_refs': []}, + 'axis-isolation': {'pass': True, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots_immutable_verified_channels': 0, 'violations': []}, + 'deviations-ratified': {'pass': True, 'declarations': [], 'exempted_by_gap_type': {}, 'expected_exempted_by_gap_type': {}, 'violations': []}, + 'closure-delta-evidenced': {'pass': True, 'reference_closure_blocking': 0, 'treatment_closure_blocking': 0, 'closed_by_gap_type': {}, 'sbom_inventory_subjects': 0, 'unexplained_closures': [], 'opened_gap_ids': []}, + 'bounds': {'pass': True, 'versions': 0, 'bound': 200000}}}""", + "gitops-no-receipts": r"""({'$schema': 'https://json-schema.org/draft/2020-12/schema', + 'authority_boundary': {'review_state': 'unreviewed', 'authoritative': False, 'compile_eligible': False, 'promote_eligible': False, 'source_admission': False, 'retrieval_release': False, 'production_mutation': False}, + 'base_manifest_id': None, + 'components': [], + 'dependency_edges': [], + 'gaps': [], + 'generation_state': 'candidate', + 'generator': {'name': 'knowledge-registry', 'ruleset_hash': 'sha256:e49f3c59e9a4f697b953166bd42e04ef0cf1a9838299fc2fd7168dc4418aa909', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'source_ref': 'tools/knowledge-registry/knowledge_registry.py#sha256:932e46cc7a68437ad6cb5eba1c8609a78d800806d8a082771807c124b2bdb6bc', 'version': '2'}, + 'input_set': {'entries': [], 'required_source_classes': []}, + 'manifest_version': 2, + 'occurrences': [], + 'record_kind': 'generated_discovery_manifest', + 'schema_version': '2.0.0', + 'sources': [], + 'versions': [], + 'bounds': {'tracked_files': 20000, 'discovery_files': 10000, 'discovery_file_bytes': 8388608, 'discovery_total_bytes': 134217728, 'json_input_bytes': 805306368, 'json_depth': 128, 'json_nodes': 20000000, 'serialized_output_bytes': 805306368, 'sources': 100000, 'components': 100000, 'versions': 200000, 'occurrences': 400000, 'dependency_edges': 700000, 'gaps': 400000}, + 'counts': {'sources': 0, 'components': 0, 'versions': 0, 'occurrences': 0, 'dependency_edges': 0, 'gaps': 0}, + 'completeness': {'input': {'state': 'unknown', 'input_count': 0, 'blocking_input_ids': []}, 'enumeration': {'state': 'unknown'}, 'closure': {'state': 'unknown', 'blocking_gap_ids': []}, 'identity': {'state': 'complete', 'blocking_gap_ids': []}, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots': {'state': 'unknown', 'accepted_available_channels': 0, 'immutable_verified_channels': 0, 'missing_channel_ids': []}, 'all_axes_complete': False}, + 'reconciliation': {'previous_manifest_id': None, 'complete_mark': False, 'removal_allowed': False, 'added': [], 'changed': [], 'missing': [], 'removed': []}, + 'integrity': {'canonicalization': 'archeion-canonical-json-v1', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'deterministic_order': True, 'exact_counts': {'sources': 0, 'components': 0, 'versions': 0, 'occurrences': 0, 'dependency_edges': 0, 'gaps': 0}, 'manifest_hash': 'sha256:fce475094eadc4363ae774df9c8867d690376c40cbee429786017b1a7560738e'}, + 'manifest_id': 'mft-fce475094eadc4363ae774df9c8867d690376c40cbee429786017b1a7560738e'}, + {'record_kind': 'gitops_identity_binding_summary', 'baseline_manifest_id': 'mft-fce475094eadc4363ae774df9c8867d690376c40cbee429786017b1a7560738e', 'observed_ref': 'refs/heads/example', 'receipts_dir': '/__fixture_root__', 'receipts_verified': 0, 'receipts_refused': 0, 'refused_receipts': [], 'commits': [], 'components_bound': 0, 'versions_bound': 0, 'bound_version_ids_digest': 'sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945', 'skipped': {}, 'fragment_manifest_id': 'mft-fce475094eadc4363ae774df9c8867d690376c40cbee429786017b1a7560738e'})""", + "oci-no-receipts": r"""({'$schema': 'https://json-schema.org/draft/2020-12/schema', + 'authority_boundary': {'review_state': 'unreviewed', 'authoritative': False, 'compile_eligible': False, 'promote_eligible': False, 'source_admission': False, 'retrieval_release': False, 'production_mutation': False}, + 'base_manifest_id': None, + 'components': [], + 'dependency_edges': [], + 'gaps': [], + 'generation_state': 'candidate', + 'generator': {'name': 'knowledge-registry', 'ruleset_hash': 'sha256:e49f3c59e9a4f697b953166bd42e04ef0cf1a9838299fc2fd7168dc4418aa909', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'source_ref': 'tools/knowledge-registry/knowledge_registry.py#sha256:932e46cc7a68437ad6cb5eba1c8609a78d800806d8a082771807c124b2bdb6bc', 'version': '2'}, + 'input_set': {'entries': [], 'required_source_classes': []}, + 'manifest_version': 2, + 'occurrences': [], + 'record_kind': 'generated_discovery_manifest', + 'schema_version': '2.0.0', + 'sources': [], + 'versions': [], + 'bounds': {'tracked_files': 20000, 'discovery_files': 10000, 'discovery_file_bytes': 8388608, 'discovery_total_bytes': 134217728, 'json_input_bytes': 805306368, 'json_depth': 128, 'json_nodes': 20000000, 'serialized_output_bytes': 805306368, 'sources': 100000, 'components': 100000, 'versions': 200000, 'occurrences': 400000, 'dependency_edges': 700000, 'gaps': 400000}, + 'counts': {'sources': 0, 'components': 0, 'versions': 0, 'occurrences': 0, 'dependency_edges': 0, 'gaps': 0}, + 'completeness': {'input': {'state': 'unknown', 'input_count': 0, 'blocking_input_ids': []}, 'enumeration': {'state': 'unknown'}, 'closure': {'state': 'unknown', 'blocking_gap_ids': []}, 'identity': {'state': 'complete', 'blocking_gap_ids': []}, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots': {'state': 'unknown', 'accepted_available_channels': 0, 'immutable_verified_channels': 0, 'missing_channel_ids': []}, 'all_axes_complete': False}, + 'reconciliation': {'previous_manifest_id': None, 'complete_mark': False, 'removal_allowed': False, 'added': [], 'changed': [], 'missing': [], 'removed': []}, + 'integrity': {'canonicalization': 'archeion-canonical-json-v1', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'deterministic_order': True, 'exact_counts': {'sources': 0, 'components': 0, 'versions': 0, 'occurrences': 0, 'dependency_edges': 0, 'gaps': 0}, 'manifest_hash': 'sha256:fce475094eadc4363ae774df9c8867d690376c40cbee429786017b1a7560738e'}, + 'manifest_id': 'mft-fce475094eadc4363ae774df9c8867d690376c40cbee429786017b1a7560738e'}, + {'record_kind': 'oci_identity_binding_summary', + 'baseline_manifest_id': 'mft-fce475094eadc4363ae774df9c8867d690376c40cbee429786017b1a7560738e', + 'receipts_dir': '/__fixture_root__', + 'receipts_verified': 0, + 'receipts_typed_failures': 0, + 'typed_failures': [], + 'receipts_refused': 0, + 'refused_receipts': [], + 'planned_refs': 0, + 'planned_refs_unreceipted': [], + 'planned_versions': 0, + 'unfetchable_version_ids': [], + 'components_bound': 0, + 'versions_bound': 0, + 'bound_version_ids_digest': 'sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945', + 'skipped': {}, + 'fragment_manifest_id': 'mft-fce475094eadc4363ae774df9c8867d690376c40cbee429786017b1a7560738e'})""", +} + + +class ManifestFixtureTestCase(FilesTestCase): + """Patch the registry's __file__ and draft202012_validator for fixture manifests.""" + + def setUp(self) -> None: + """Isolate generator files and the schema engine from behavioral tests.""" + super().setUp() + generator = self.write(kr.GENERATOR_SOURCE_REF, "# fixture generator\n") + self.write(kr.DISCOVERY_SCHEMA_RELATIVE, "{}") + self.enterContext(patch.object(kr, "__file__", str(generator))) + validator = Mock() + validator.iter_errors.return_value = () + self.enterContext( + patch.object(kr, "draft202012_validator", return_value=validator) + ) + + def receipt(self, uri: str, subject: str, data: bytes) -> Record: + """Store receipt bytes under their digest and return a receipt row.""" + content_hash = "sha256:" + hashlib.sha256(data).hexdigest() + cas_path = f"cas/{content_hash[7:]}" + self.write(cas_path, data) + return { + "canonical_uri": uri, + "resolved_uri": uri, + "channel_ids": [subject], + "observed_at": OBSERVED, + "fetched_at": OBSERVED, + "content_hash": content_hash, + "cas_path": cas_path, + "status": "verified", + } + + def write_receipts(self, *rows: Record) -> None: + """Write the receipt JSONL consumed by registry binders.""" + if len(rows) > MAX_FIXTURE_ROWS: + raise AssertionError( + f"receipt batch exceeds {MAX_FIXTURE_ROWS} fixture rows" + ) + self.write( + "receipts/input.jsonl", "".join(json.dumps(row) + "\n" for row in rows) + ) + + def snapshot_fixture(self) -> tuple[Record, Record, str, str]: + """Create one accepted channel and its bindable package version.""" + builder, component, version = package_builder() + record = kr.derived_component_record( + policy_entry(), + builder.components[component], + "pkg:pypi/app", + "baseline", + "input.json", + ) + (channel,) = record["channels"] + builder.components[component]["official_channels"] = [channel] + return builder.manifest(), record, str(channel["channel_id"]), version + + def oci_receipt(self, version: str, architecture: str) -> Record: + """Write single-platform OCI manifest and config bytes with matching digests.""" + config = json.dumps({"os": "linux", "architecture": architecture}).encode() + config_hash = "sha256:" + hashlib.sha256(config).hexdigest() + config_path = f"cas/{config_hash[7:]}" + self.write(config_path, config) + data = json.dumps( + { + "schemaVersion": 2, + "mediaType": OCI_MEDIA, + "config": {"digest": config_hash}, + "layers": [], + } + ).encode() + row = self.receipt(OCI_URI, version, data) + row["media_type"] = OCI_MEDIA + row["coordinates"] = { + "oci": { + "registry": OCI_REGISTRY, + "repository": OCI_REPOSITORY, + "reference": "1.2.3", + "reference_kind": "tag", + "resolved_digest": row["content_hash"], + "kind": "manifest", + "config_content_hash": config_hash, + "config_cas_path": config_path, + "platforms": [f"linux/{architecture}"], + "children": [], + "excluded": [], + } + } + return row + + +class ChannelWaveTests(ManifestFixtureTestCase): + """Build channel policy waves, snapshot receipts, and comparison manifests.""" + + def test_derive_channel_records(self) -> None: + """Emit matching records and samples and skip failed preconditions.""" + builder, _component, _ = package_builder() + baseline = builder.manifest() + entry = policy_entry() + closed, _, _, _ = self.snapshot_fixture() + check_output( + self, + EXPECTED, + "test_derive_channel_records.1", + kr.derive_channel_records, + closed, + [entry], + ) + check_output( + self, + EXPECTED, + "test_derive_channel_records.2", + kr.derive_channel_records, + baseline, + [entry], + ) + + entry["preconditions"] = [("name", re.compile("^other$"))] + check_output( + self, + EXPECTED, + "test_derive_channel_records.3", + kr.derive_channel_records, + baseline, + [entry], + ) + with self.assertRaisesRegex( + kr.RegistryInputError, "derive-channels baseline is invalid" + ): + check_output( + self, + EXPECTED, + "test_derive_channel_records.4", + kr.derive_channel_records, + {}, + [entry], + ) + + def test_channel_wave_gate(self) -> None: + """Check the declared wave size and reject a component delta.""" + builder, _, _ = package_builder() + baseline = builder.manifest() + check_output( + self, + EXPECTED, + "test_channel_wave_gate.1", + kr.channel_wave_gate, + baseline, + baseline, + policies=[], + expected_matched=0, + ) + check_output( + self, + EXPECTED, + "test_channel_wave_gate.2", + kr.channel_wave_gate, + baseline, + baseline, + policies=[], + expected_matched=1, + ) + + builder.add_component( + kind="library", + ecosystem="pypi", + name="other", + purl="pkg:pypi/other", + official_channel_required=False, + ) + check_output( + self, + EXPECTED, + "test_channel_wave_gate.3", + kr.channel_wave_gate, + baseline, + kr.Builder().manifest(), + policies=[], + expected_matched=0, + ) + check_output( + self, + EXPECTED, + "test_channel_wave_gate.4", + kr.channel_wave_gate, + baseline, + builder.manifest(), + policies=[], + expected_matched=0, + ) + + def test_bind_channel_snapshot_receipts(self) -> None: + """Bind verified CAS bytes and report receipts for unknown channels.""" + baseline, record, channel, _version = self.snapshot_fixture() + component = record["component"]["component_id"] + row = self.receipt(CHANNEL_URI, channel, b"fixture snapshot\n") + other = {**row, "channel_ids": ["chn:other"]} + self.write_receipts(row, other) + check_output( + self, + EXPECTED, + "test_bind_channel_snapshot_receipts.1", + kr.bind_channel_snapshot_receipts, + [(component, record)], + baseline, + str(self.root), + ) + + def test_bind_channel_snapshot_receipts_conflict(self) -> None: + """Reject distinct verified bytes for the same available channel.""" + baseline, record, channel, _ = self.snapshot_fixture() + component = record["component"]["component_id"] + row = self.receipt(CHANNEL_URI, channel, b"fixture snapshot\n") + other = self.receipt(CHANNEL_URI, channel, b"other fixture snapshot\n") + existing = [(component, record)] + third = self.receipt(CHANNEL_URI, channel, b"third fixture snapshot\n") + self.write_receipts(row, other, third) + check_output( + self, + EXPECTED, + "test_bind_channel_snapshot_receipts_conflict.1", + kr.bind_channel_snapshot_receipts, + existing, + baseline, + str(self.root), + ) + + def test_bind_channel_snapshot_receipts_rejects_uri_mismatch(self) -> None: + """Refuse a verified receipt with a known channel ID and a different URI.""" + baseline, record, channel, _ = self.snapshot_fixture() + component = record["component"]["component_id"] + row = self.receipt("https://example.net/app", channel, b"fixture snapshot\n") + self.write_receipts(row) + check_output( + self, + EXPECTED, + "test_bind_channel_snapshot_receipts_rejects_uri_mismatch.1", + kr.bind_channel_snapshot_receipts, + [(component, record)], + baseline, + str(self.root), + ) + + def test_channel_snapshot_gate_detects_corrupt_cas(self) -> None: + """Reject a verified receipt whose object no longer matches its digest.""" + baseline, _, channel, _ = self.snapshot_fixture() + row = self.receipt(CHANNEL_URI, channel, b"fixture snapshot\n") + self.write(row["cas_path"], b"corrupt bytes\n") + self.write_receipts(row) + check_output( + self, + EXPECTED, + "test_channel_snapshot_gate_detects_corrupt_cas.1", + kr.channel_snapshot_gate, + baseline, + baseline, + receipts_dir=str(self.root), + ) + + def test_channel_snapshot_gate(self) -> None: + """Require a traced snapshot for each bindable receipt.""" + baseline, record, channel, _ = self.snapshot_fixture() + component = record["component"]["component_id"] + row = self.receipt(CHANNEL_URI, channel, b"fixture snapshot\n") + self.write_receipts(row) + check_output( + self, + EXPECTED, + "test_channel_snapshot_gate.1", + kr.channel_snapshot_gate, + baseline, + baseline, + receipts_dir=str(self.root), + ) + + check_output( + self, + EXPECTED, + "test_channel_snapshot_gate.2", + kr.bind_channel_snapshot_receipts, + [(component, record)], + baseline, + str(self.root), + ) + (original,) = baseline["components"] + changed = {**original, "official_channel_snapshots": record["snapshots"]} + merged = kr.seal_manifest({**baseline, "components": [changed]}) + check_output( + self, + EXPECTED, + "test_channel_snapshot_gate.3", + kr.channel_snapshot_gate, + baseline, + merged, + receipts_dir=str(self.root), + ) + + added_builder, _, _added_id = package_builder(observed="1.2.4") + added = only(added_builder.versions) + changed = kr.seal_manifest({**merged, "versions": [*merged["versions"], added]}) + check_output( + self, + EXPECTED, + "test_channel_snapshot_gate.4", + kr.channel_snapshot_gate, + baseline, + changed, + receipts_dir=str(self.root), + ) + + def test_channel_derivation_empty_and_no_policy(self) -> None: + """Count no candidates or policies without emitting reviewed records.""" + check_output( + self, + EXPECTED, + "derive-empty", + kr.derive_channel_records, + kr.Builder().manifest(), + [], + ) + builder, _, _ = package_builder() + check_output( + self, + EXPECTED, + "derive-no-policy", + kr.derive_channel_records, + builder.manifest(), + [], + ) + disabled, _, _ = package_builder(required=False) + check_output( + self, + EXPECTED, + "derive-not-required", + kr.derive_channel_records, + disabled.manifest(), + [policy_entry()], + ) + + def test_channel_derivation_matching_precondition_and_live_pointer(self) -> None: + """Match an explicit selector and prefer the earliest live evidence pointer.""" + builder, component, _ = package_builder() + builder.add_version( + component, + resolved_version="1.2.3", + evidence=("live-export:widgets.json#/b", "live-export:widgets.json#/a"), + ) + entry = policy_entry("{evidence_document}") + entry["preconditions"] = [("name", re.compile("^app$"))] + check_output( + self, + EXPECTED, + "derive-matching", + kr.derive_channel_records, + builder.manifest(), + [entry], + ) + + def test_channel_snapshot_receipts_no_bindable_version(self) -> None: + """Report a verified channel row when the reviewed schema cannot express a version.""" + baseline, record, channel, _ = self.snapshot_fixture() + component = record["component"]["component_id"] + row = self.receipt(CHANNEL_URI, channel, b"fixture snapshot\n") + self.write_receipts(row) + check_output( + self, + EXPECTED, + "snapshot-no-bindable", + kr.bind_channel_snapshot_receipts, + [(component, record)], + {**baseline, "versions": []}, + str(self.root), + ) + + def test_channel_snapshot_receipts_corrupt_and_empty(self) -> None: + """Give corrupt content a refusal and keep an empty batch unbound.""" + baseline, record, channel, _ = self.snapshot_fixture() + component = record["component"]["component_id"] + row = self.receipt(CHANNEL_URI, channel, b"fixture snapshot\n") + self.write(row["cas_path"], b"changed") + self.write_receipts(row) + check_output( + self, + EXPECTED, + "snapshot-cas-corrupt", + kr.bind_channel_snapshot_receipts, + [(component, record)], + baseline, + str(self.root), + ) + self.write_receipts() + check_output( + self, + EXPECTED, + "snapshot-no-receipts", + kr.bind_channel_snapshot_receipts, + [], + baseline, + str(self.root), + ) + + def test_channel_gates_invalid_treatment(self) -> None: + """Report invalid merged manifests and allow absent expected wave size.""" + baseline = kr.Builder().manifest() + self.write_receipts() + check_output( + self, + EXPECTED, + "wave-invalid", + kr.channel_wave_gate, + baseline, + {}, + policies=[], + ) + check_output( + self, + EXPECTED, + "snapshot-invalid", + kr.channel_snapshot_gate, + baseline, + {}, + receipts_dir=str(self.root), + ) + + def test_wave_detects_unaccepted_channel_and_bad_bindings(self) -> None: + """Refuse an available proposal and mismatched stamps at both evidence sites.""" + baseline, record, _channel_id, _version = self.snapshot_fixture() + (component,) = baseline["components"] + (channel,) = record["channels"] + invalid_hash = "sha256:" + "b" * 64 + reviewer = f"channel-policy:fixture-policy@{invalid_hash}" + citation = f"policy.json@{invalid_hash}" + merged = { + **baseline, + "components": [ + { + **component, + "metadata": { + "review": {"reviewed_by": reviewer, "evidence": [citation]} + }, + "official_channels": [ + {**channel, "review_state": "proposed", "evidence": [citation]} + ], + } + ], + } + with patch.object(kr, "validate_manifest", return_value=[]): + report = kr.channel_wave_gate(baseline, merged, policies=[policy_entry()]) + self.assertEqual( + report, ast.literal_eval(EXPECTED["wave-unaccepted-bad-bindings"]) + ) + + def test_snapshot_gate_detects_mismatched_and_failure_receipts(self) -> None: + """Report an unknown channel, wrong URI, and unrepresented failure.""" + baseline, _, channel, _ = self.snapshot_fixture() + self.write_receipts( + self.receipt("https://example.net/app", channel, b"fixture mismatch"), + self.receipt(CHANNEL_URI, "chn:other", b"fixture unknown"), + { + **self.receipt(CHANNEL_URI, channel, b"fixture failure"), + "status": "failed", + }, + ) + report = kr.channel_snapshot_gate( + baseline, baseline, receipts_dir=str(self.root) + ) + self.assertEqual( + report, ast.literal_eval(EXPECTED["snapshot-mismatched-and-failed"]) + ) + + +class IdentityTests(ManifestFixtureTestCase): + """Build Git and OCI receipts and compare control, treatment, and anchor manifests.""" + + def test_bind_gitops_identity(self) -> None: + """Bind a verified commit to a mutable ref without reminting the version.""" + builder = kr.Builder() + component = builder.add_component( + kind="git-repository", + ecosystem="git", + name="self", + identity="git:repository:self", + metadata={"self_repository": True}, + official_channel_required=False, + ) + builder.add_version(component, source_ref="main", evidence=("input.json",)) + other = builder.add_component( + kind="git-repository", + ecosystem="git", + name="other", + identity="git:repository:other", + metadata={"self_repository": False}, + official_channel_required=False, + ) + builder.add_version(other, source_ref="main", evidence=("input.json",)) + baseline = builder.manifest() + data = ( + f"tree {'a' * 40}\nauthor Example 1767323045 +0000\n" + "committer Example 1767323045 +0000\n\nfixture\n" + ).encode() + commit = hashlib.sha1(f"commit {len(data)}\0".encode() + data).hexdigest() + row = self.receipt( + "https://git.example.org/example/app", + f"chn:fixture:{component}:source", + data, + ) + row["channel_ids"].append(f"chn:fixture:{other}:source") + row.update(media_type=kr.GITOPS_COMMIT_MEDIA_TYPE, upstream_ref=commit) + self.write_receipts(row) + check_output( + self, + EXPECTED, + "test_bind_gitops_identity.1", + kr.bind_gitops_identity, + baseline, + str(self.root), + observed_ref="MAIN", + ) + with self.assertRaisesRegex(kr.RegistryInputError, "is not a mutable ref"): + check_output( + self, + EXPECTED, + "test_bind_gitops_identity.2", + kr.bind_gitops_identity, + baseline, + str(self.root), + observed_ref=commit, + ) + + def test_bind_oci_identity(self) -> None: + """Bind OCI manifest identity and reject conflicting receipts for one tag.""" + builder, source = source_builder() + _, version, _ = builder.add_image( + f"{OCI_REGISTRY}/{OCI_REPOSITORY}:1.2.3", source, "/image", "fixture-image" + ) + baseline = builder.manifest() + row = self.oci_receipt(version, "amd64") + newer = {**row, "observed_at": LATER, "fetched_at": LATER} + self.write_receipts(newer, row) + check_output( + self, + EXPECTED, + "test_bind_oci_identity.1", + kr.bind_oci_identity, + baseline, + str(self.root), + ) + + conflicting = self.oci_receipt(version, "arm64") + self.write_receipts(row, conflicting) + with self.assertRaisesRegex( + kr.RegistryInputError, "disagree on the identity.*2 distinct manifests" + ): + check_output( + self, + EXPECTED, + "test_bind_oci_identity.2", + kr.bind_oci_identity, + baseline, + str(self.root), + ) + + def test_identity_gate(self) -> None: + """Require every added version to appear in the expected plan.""" + builder, component, _ = package_builder(required=False) + control = builder.manifest() + new_version = builder.add_version(component, resolved_version="1.2.4") + treatment = builder.manifest() + self.write_receipts() + check_output( + self, + EXPECTED, + "test_identity_gate.1", + kr.identity_gate, + control, + treatment, + receipts_dir=str(self.root), + anchor=control, + ) + check_output( + self, + EXPECTED, + "test_identity_gate.2", + kr.identity_gate, + control, + treatment, + receipts_dir=str(self.root), + anchor=control, + expected_plan={"expected_new_version_ids": [new_version]}, + ) + + anchor = kr.Builder().manifest() + check_output( + self, + EXPECTED, + "test_identity_gate.3", + kr.identity_gate, + control, + anchor, + receipts_dir=str(self.root), + anchor=control, + ) + check_output( + self, + EXPECTED, + "test_identity_gate.4", + kr.identity_gate, + control, + treatment, + receipts_dir=str(self.root), + anchor=anchor, + expected_plan={"expected_new_version_ids": [new_version]}, + ) + + def test_identity_gates_empty_inputs(self) -> None: + """Report empty receipt collections and invalid input manifests.""" + baseline = kr.Builder().manifest() + self.write_receipts() + check_output( + self, + EXPECTED, + "identity-empty", + kr.identity_gate, + baseline, + baseline, + receipts_dir=str(self.root), + ) + check_output( + self, + EXPECTED, + "identity-invalid", + kr.identity_gate, + baseline, + {}, + receipts_dir=str(self.root), + ) + check_output( + self, + EXPECTED, + "gitops-no-receipts", + kr.bind_gitops_identity, + baseline, + str(self.root), + observed_ref="refs/heads/example", + ) + check_output( + self, + EXPECTED, + "oci-no-receipts", + kr.bind_oci_identity, + baseline, + str(self.root), + ) + + def test_identity_binders_reject_invalid_baseline(self) -> None: + """Return the complete two-error message before opening any receipts.""" + with patch.object( + kr, "validate_manifest", return_value=["fixture first", "fixture second"] + ): + for bind in (kr.bind_gitops_identity, kr.bind_oci_identity): + with self.subTest(bind=bind.__name__): + with self.assertRaises(kr.RegistryInputError) as caught: + bind({}, str(self.root)) + self.assertEqual( + (type(caught.exception), str(caught.exception)), + ( + kr.RegistryInputError, + "baseline is invalid: fixture first; fixture second", + ), + ) diff --git a/tools/knowledge-registry/tests/test_registry_function_net_cli.py b/tools/knowledge-registry/tests/test_registry_function_net_cli.py new file mode 100644 index 0000000..d928fb8 --- /dev/null +++ b/tools/knowledge-registry/tests/test_registry_function_net_cli.py @@ -0,0 +1,1483 @@ +# SPDX-FileCopyrightText: 2026 Lusoris +# SPDX-License-Identifier: EUPL-1.2 + +from __future__ import annotations + +import errno +import io +import json +import os +import sys +import unittest +from contextlib import ExitStack, redirect_stderr, redirect_stdout +from pathlib import Path +from unittest.mock import patch + +# Resolve sibling fixtures in this checkout even when another net was loaded earlier. +fixture_dir = Path(__file__).resolve().parent +with patch.dict(sys.modules): + for sibling in ( + "test_registry_function_net", + "test_registry_function_net_channels", + ): + cached_path = getattr(sys.modules.get(sibling), "__file__", None) + if cached_path is None or Path(cached_path).resolve().parent != fixture_dir: + sys.modules.pop(sibling, None) + with patch.object(sys, "path", [str(fixture_dir), *sys.path]): + from test_registry_function_net import ( + CHANNEL_URI, + DIGEST, + LATER, + OBSERVED, + FilesTestCase, + Record, + check_output, + kr, + live, + local_builder, + ) + from test_registry_function_net_channels import ( + ManifestFixtureTestCase, + package_builder, + policy_entry, + ) + + +EXPECTED: dict[str, str] = { + "chart-lock-missing-entry": r"""(None, + {'sources': [('src-1572cd6aa962300e1955906a', {'content_hash': 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'evidence_uri': 'Chart.lock', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-1572cd6aa962300e1955906a', 'source_type': 'helm-chart-lock'}), + ('src-87186594c915fffba221ed49', {'content_hash': 'sha256:7bbded9435491a9c17f3fa146298f93c0a46ac616fe517a71dfe3f7eb373ea3f', 'evidence_uri': 'Chart.yaml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-87186594c915fffba221ed49', 'source_type': 'helm-chart-metadata'})], + 'components': [('cmp-10e5b92b9c672353486d6b0d', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-6512cc76719e470e437585ca', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'component_version_id': 'ver-6512cc76719e470e437585ca', 'evidence': ['Chart.yaml'], 'resolution_state': 'resolved', 'resolved_version': '2.0.0', 'source_ref': 'sha256:7bbded9435491a9c17f3fa146298f93c0a46ac616fe517a71dfe3f7eb373ea3f'})], + 'occurrences': [], + 'edges': [], + 'extra_gaps': [('gap-cb02cd97a73d6f8549514d9d', {'component_id': 'cmp-10e5b92b9c672353486d6b0d', 'component_version_id': 'ver-6512cc76719e470e437585ca', 'evidence': ['Chart.lock#L4'], 'gap_id': 'gap-cb02cd97a73d6f8549514d9d', 'gap_type': 'helm-lock-entry-missing', 'message': "Chart.lock does not lock declared dependency 'child'", 'source_id': 'src-1572cd6aa962300e1955906a'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "chart-lock-no-sibling": r"""(None, + {'sources': [('src-40f7b9bd89a2d31c49d1c1a7', {'content_hash': 'sha256:1aa3dc798aac40bd127a805756f38f6de566a48919d6efe1b529fc80faaa1fb9', 'evidence_uri': 'Chart.lock', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-40f7b9bd89a2d31c49d1c1a7', 'source_type': 'helm-chart-lock'})], + 'components': [('cmp-faeaf465b92612d22be57e87', {'component_id': 'cmp-faeaf465b92612d22be57e87', 'ecosystem': 'local', 'kind': 'helm-lock', 'lifecycles': ['repository-used'], 'name': 'Chart.lock', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), ('cmp-d3f8451d31a4b4ccfb96ae72', {'component_id': 'cmp-d3f8451d31a4b4ccfb96ae72', 'ecosystem': 'helm', 'kind': 'helm-chart', 'lifecycles': ['repository-used'], 'name': 'child', 'namespace': '', 'official_channel_required': True, 'official_channels': []})], + 'versions': [('ver-42c362d89b652c638e19b99e', {'component_id': 'cmp-faeaf465b92612d22be57e87', 'component_version_id': 'ver-42c362d89b652c638e19b99e', 'evidence': ['Chart.lock'], 'resolution_state': 'resolved', 'source_ref': 'sha256:1aa3dc798aac40bd127a805756f38f6de566a48919d6efe1b529fc80faaa1fb9'}), ('ver-3587c5ed82ee40f5e0569085', {'component_id': 'cmp-d3f8451d31a4b4ccfb96ae72', 'component_version_id': 'ver-3587c5ed82ee40f5e0569085', 'evidence': ['Chart.lock#L2'], 'resolution_state': 'unresolved'})], + 'occurrences': [('occ-eb512a14a03d13d10f03ee0f', {'component_id': 'cmp-d3f8451d31a4b4ccfb96ae72', 'component_version_id': 'ver-3587c5ed82ee40f5e0569085', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': 'line:2:lock:0', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-eb512a14a03d13d10f03ee0f', 'optional': False, 'raw_value': 'child@', 'role': 'helm-locked-dependency', 'root_id': 'cmp-faeaf465b92612d22be57e87', 'source_id': 'src-40f7b9bd89a2d31c49d1c1a7'})], + 'edges': [('edge-77eb406383602528a7d33ce4', {'edge_id': 'edge-77eb406383602528a7d33ce4', 'from_component_version_id': 'ver-42c362d89b652c638e19b99e', 'optional': False, 'relationship': 'locks', 'resolver': 'helm-lock', 'scope': 'runtime', 'source_occurrence_id': 'occ-eb512a14a03d13d10f03ee0f', 'to_component_version_id': 'ver-3587c5ed82ee40f5e0569085'})], + 'extra_gaps': [('gap-79502360d7377c7c49740429', {'component_id': 'cmp-faeaf465b92612d22be57e87', 'component_version_id': 'ver-42c362d89b652c638e19b99e', 'evidence': ['Chart.lock'], 'gap_id': 'gap-79502360d7377c7c49740429', 'gap_type': 'helm-chart-root-missing', 'message': 'Chart.lock has no sibling Chart.yaml to own its locked dependencies', 'source_id': 'src-40f7b9bd89a2d31c49d1c1a7'}), + ('gap-0470daea2d9091c84c034558', {'component_id': 'cmp-faeaf465b92612d22be57e87', 'component_version_id': 'ver-42c362d89b652c638e19b99e', 'evidence': ['Chart.lock'], 'gap_id': 'gap-0470daea2d9091c84c034558', 'gap_type': 'helm-lock-untracked', 'message': 'Chart.lock supplies exact dependency versions but is ignored/untracked', 'source_id': 'src-40f7b9bd89a2d31c49d1c1a7'}), + ('gap-aa15ec6adbf48a444e6566ff', {'component_id': 'cmp-faeaf465b92612d22be57e87', 'component_version_id': 'ver-42c362d89b652c638e19b99e', 'evidence': ['Chart.lock#L2'], 'gap_id': 'gap-aa15ec6adbf48a444e6566ff', 'gap_type': 'helm-lock-dependency-undeclared', 'message': "Chart.lock locks undeclared dependency 'child'", 'source_id': 'src-40f7b9bd89a2d31c49d1c1a7'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "codex-missing": "(None, {'sources': [], 'components': [], 'versions': [], 'occurrences': [], 'edges': [], 'extra_gaps': [], 'discovery_inputs': [], 'node_platforms': []})", + "codex-empty": r"""(None, + {'sources': [('src-37d1d97c5ba0caa2519e09ba', {'content_hash': 'sha256:e11d8f2c76c401cfee5870c24e805d1745ca0c1ef4beb525b9258faece8dc9ae', 'evidence_uri': 'config.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-37d1d97c5ba0caa2519e09ba', 'source_type': 'codex-config'})], + 'components': [('cmp-0e2047679351ff658356304a', {'component_id': 'cmp-0e2047679351ff658356304a', 'ecosystem': 'local', 'kind': 'codex-config', 'lifecycles': ['repository-used'], 'name': 'config.toml', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-3b773ac41cc12bc88741fcb0', {'component_id': 'cmp-0e2047679351ff658356304a', 'component_version_id': 'ver-3b773ac41cc12bc88741fcb0', 'evidence': ['config.toml'], 'resolution_state': 'resolved', 'source_ref': 'sha256:e11d8f2c76c401cfee5870c24e805d1745ca0c1ef4beb525b9258faece8dc9ae'})], + 'occurrences': [], + 'edges': [], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "codex-non-table-entry": r"""(None, + {'sources': [('src-de779db89e5e65b360cd3856', {'content_hash': 'sha256:99d773d95e68b6a3c84790cff06827e4899cf695a9196f84c46c430b76d96e26', 'evidence_uri': 'config.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-de779db89e5e65b360cd3856', 'source_type': 'codex-config'})], + 'components': [('cmp-0e2047679351ff658356304a', {'component_id': 'cmp-0e2047679351ff658356304a', 'ecosystem': 'local', 'kind': 'codex-config', 'lifecycles': ['repository-used'], 'name': 'config.toml', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-3d43fce0d3a249227c657630', {'component_id': 'cmp-0e2047679351ff658356304a', 'component_version_id': 'ver-3d43fce0d3a249227c657630', 'evidence': ['config.toml'], 'resolution_state': 'resolved', 'source_ref': 'sha256:99d773d95e68b6a3c84790cff06827e4899cf695a9196f84c46c430b76d96e26'})], + 'occurrences': [], + 'edges': [], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "containerd-no-endpoints": "(None, {'sources': [], 'components': [], 'versions': [], 'occurrences': [], 'edges': [], 'extra_gaps': [], 'discovery_inputs': [], 'node_platforms': []})", + "containerd-bare-mirror": r"""(None, + {'sources': [('src-a269f7570ea690bc3b7103db', {'content_hash': 'sha256:942754740c07ed8d53e4c2a42558d7260eb11d71b4b8b02edc085a1eff611c05', 'evidence_uri': 'hosts.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-a269f7570ea690bc3b7103db', 'source_type': 'containerd-hosts'})], + 'components': [('cmp-bf447d20dea721e92f1f0db9', {'component_id': 'cmp-bf447d20dea721e92f1f0db9', 'ecosystem': 'local', 'kind': 'containerd-hosts', 'lifecycles': ['repository-used'], 'name': 'hosts.toml', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-1ceabc92035cd5e96035d3c2', {'component_id': 'cmp-1ceabc92035cd5e96035d3c2', 'ecosystem': 'oci-registry', 'kind': 'registry-endpoint', 'lifecycles': ['repository-used'], 'metadata': {'endpoint': 'https://mirror.example.org'}, 'name': 'https://mirror.example.org', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-7b71971e750bdf1821280167', {'component_id': 'cmp-bf447d20dea721e92f1f0db9', 'component_version_id': 'ver-7b71971e750bdf1821280167', 'evidence': ['hosts.toml'], 'resolution_state': 'resolved', 'source_ref': 'sha256:942754740c07ed8d53e4c2a42558d7260eb11d71b4b8b02edc085a1eff611c05'}), + ('ver-1531f7c8af214e2f02ffd4cf', {'component_id': 'cmp-1ceabc92035cd5e96035d3c2', 'component_version_id': 'ver-1531f7c8af214e2f02ffd4cf', 'evidence': ['hosts.toml#L1'], 'resolution_state': 'resolved', 'source_ref': 'sha256:942754740c07ed8d53e4c2a42558d7260eb11d71b4b8b02edc085a1eff611c05'})], + 'occurrences': [('occ-e6c50923a39c998c5b176143', {'component_id': 'cmp-1ceabc92035cd5e96035d3c2', 'component_version_id': 'ver-1531f7c8af214e2f02ffd4cf', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': 'line:1', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-e6c50923a39c998c5b176143', 'optional': False, 'raw_value': 'https://mirror.example.org', 'role': 'containerd-registry-mirror', 'root_id': 'cmp-bf447d20dea721e92f1f0db9', 'source_id': 'src-a269f7570ea690bc3b7103db'})], + 'edges': [('edge-4076c6e36232d1e602b5977a', {'edge_id': 'edge-4076c6e36232d1e602b5977a', 'from_component_version_id': 'ver-7b71971e750bdf1821280167', 'optional': False, 'relationship': 'routes-through', 'resolver': 'containerd-hosts', 'scope': 'deployment', 'source_occurrence_id': 'occ-e6c50923a39c998c5b176143', 'to_component_version_id': 'ver-1531f7c8af214e2f02ffd4cf'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "containerd-server-only": r"""(None, + {'sources': [('src-e236ea4b52b29f4dfb218701', {'content_hash': 'sha256:b6d2095ab3fbd9c1adcdd8e5891c7357c87e085f52572e066b59f479b896c22f', 'evidence_uri': 'hosts.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-e236ea4b52b29f4dfb218701', 'source_type': 'containerd-hosts'})], + 'components': [('cmp-bf447d20dea721e92f1f0db9', {'component_id': 'cmp-bf447d20dea721e92f1f0db9', 'ecosystem': 'local', 'kind': 'containerd-hosts', 'lifecycles': ['repository-used'], 'name': 'hosts.toml', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), + ('cmp-46b2866a7f560d01e5a21285', {'component_id': 'cmp-46b2866a7f560d01e5a21285', 'ecosystem': 'oci-registry', 'kind': 'registry-endpoint', 'lifecycles': ['repository-used'], 'metadata': {'endpoint': 'https://registry.example.org'}, 'name': 'https://registry.example.org', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-a9f50b9927ceb502d1946eb8', {'component_id': 'cmp-bf447d20dea721e92f1f0db9', 'component_version_id': 'ver-a9f50b9927ceb502d1946eb8', 'evidence': ['hosts.toml'], 'resolution_state': 'resolved', 'source_ref': 'sha256:b6d2095ab3fbd9c1adcdd8e5891c7357c87e085f52572e066b59f479b896c22f'}), + ('ver-407b65231685a56385635d01', {'component_id': 'cmp-46b2866a7f560d01e5a21285', 'component_version_id': 'ver-407b65231685a56385635d01', 'evidence': ['hosts.toml#L2'], 'resolution_state': 'resolved', 'source_ref': 'sha256:b6d2095ab3fbd9c1adcdd8e5891c7357c87e085f52572e066b59f479b896c22f'})], + 'occurrences': [('occ-05ff7cca6dbca118ef11d758', {'component_id': 'cmp-46b2866a7f560d01e5a21285', 'component_version_id': 'ver-407b65231685a56385635d01', 'dependency_scope': 'deployment', 'directness': 'direct', 'evidence_locator': 'line:2', 'lifecycle': 'repository-used', 'metadata': {'registry_server': True}, 'occurrence_id': 'occ-05ff7cca6dbca118ef11d758', 'optional': False, 'raw_value': 'https://registry.example.org', 'role': 'containerd-registry-server', 'root_id': 'cmp-bf447d20dea721e92f1f0db9', 'source_id': 'src-e236ea4b52b29f4dfb218701'})], + 'edges': [('edge-90ec13e22aed359243a152dd', {'edge_id': 'edge-90ec13e22aed359243a152dd', 'from_component_version_id': 'ver-a9f50b9927ceb502d1946eb8', 'metadata': {'registry_server': True}, 'optional': False, 'relationship': 'configures', 'resolver': 'containerd-hosts', 'scope': 'deployment', 'source_occurrence_id': 'occ-05ff7cca6dbca118ef11d758', 'to_component_version_id': 'ver-407b65231685a56385635d01'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "containerd-empty-hosts": r"""(None, + {'sources': [('src-480411c63379051b3963ae00', {'content_hash': 'sha256:68a47e0c62f73bd218aa5b090bc1477912cbd9d24ce0d19b62ff105e7f92c463', 'evidence_uri': 'hosts.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-480411c63379051b3963ae00', 'source_type': 'containerd-hosts'})], + 'components': [('cmp-bf447d20dea721e92f1f0db9', {'component_id': 'cmp-bf447d20dea721e92f1f0db9', 'ecosystem': 'local', 'kind': 'containerd-hosts', 'lifecycles': ['repository-used'], 'name': 'hosts.toml', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-a75d432643edde5efeb1f217', {'component_id': 'cmp-bf447d20dea721e92f1f0db9', 'component_version_id': 'ver-a75d432643edde5efeb1f217', 'evidence': ['hosts.toml'], 'resolution_state': 'resolved', 'source_ref': 'sha256:68a47e0c62f73bd218aa5b090bc1477912cbd9d24ce0d19b62ff105e7f92c463'})], + 'occurrences': [], + 'edges': [], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "pyproject-defaults": r"""(None, + {'sources': [('src-4c677a33f142585f412bd332', {'content_hash': 'sha256:b9ffb22a624a641e612694b272f124324ec0f7892988ce2b1fbd552239ea8c45', 'evidence_uri': 'app/pyproject.toml', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-4c677a33f142585f412bd332', 'source_type': 'python-pyproject'})], + 'components': [('cmp-05eda4d7a3fe7d6f7761cd4a', {'component_id': 'cmp-05eda4d7a3fe7d6f7761cd4a', 'ecosystem': 'pypi', 'kind': 'python-project', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': [], 'purl': 'pkg:pypi/app'}), + ('cmp-257fc68c98b4e395108581b2', {'component_id': 'cmp-257fc68c98b4e395108581b2', 'ecosystem': 'pypi', 'kind': 'library', 'lifecycles': ['repository-used'], 'name': 'example-dep', 'namespace': '', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:pypi/example-dep'}), + ('cmp-6a8a2cf681f7297195a653fc', {'component_id': 'cmp-6a8a2cf681f7297195a653fc', 'ecosystem': 'pypi', 'kind': 'library', 'lifecycles': ['repository-used'], 'name': 'other', 'namespace': '', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:pypi/other'})], + 'versions': [('ver-45e5c3cd0ec04cedd2a6c9ff', {'component_id': 'cmp-05eda4d7a3fe7d6f7761cd4a', 'component_version_id': 'ver-45e5c3cd0ec04cedd2a6c9ff', 'evidence': ['app/pyproject.toml'], 'resolution_state': 'resolved', 'source_ref': 'sha256:b9ffb22a624a641e612694b272f124324ec0f7892988ce2b1fbd552239ea8c45'}), ('ver-5a2258d36e1f956f0c7bbad3', {'component_id': 'cmp-257fc68c98b4e395108581b2', 'component_version_id': 'ver-5a2258d36e1f956f0c7bbad3', 'evidence': ['app/pyproject.toml#line:2:column:17'], 'resolution_state': 'unresolved'}), + ('ver-c25c205dec3e1c5f0566706f', {'component_id': 'cmp-6a8a2cf681f7297195a653fc', 'component_version_id': 'ver-c25c205dec3e1c5f0566706f', 'evidence': ['app/pyproject.toml#line:2:column:39'], 'metadata': {'marker': 'python_version < 3.15'}, 'resolution_state': 'unresolved'})], + 'occurrences': [('occ-1bce1232778eebbe80ba4783', {'component_id': 'cmp-257fc68c98b4e395108581b2', 'component_version_id': 'ver-5a2258d36e1f956f0c7bbad3', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': 'line:2:column:17', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-1bce1232778eebbe80ba4783', 'optional': True, 'raw_value': 'Example_Dep', 'role': 'pyproject-dependency', 'root_id': 'cmp-05eda4d7a3fe7d6f7761cd4a', 'source_id': 'src-4c677a33f142585f412bd332'}), + ('occ-bac5af596371ff67bbb98d78', {'component_id': 'cmp-6a8a2cf681f7297195a653fc', 'component_version_id': 'ver-c25c205dec3e1c5f0566706f', 'dependency_scope': 'runtime', 'directness': 'direct', 'evidence_locator': 'line:2:column:39', 'lifecycle': 'repository-used', 'metadata': {'marker': 'python_version < 3.15'}, 'occurrence_id': 'occ-bac5af596371ff67bbb98d78', 'optional': False, 'raw_value': 'other', 'role': 'pyproject-dependency', 'root_id': 'cmp-05eda4d7a3fe7d6f7761cd4a', 'source_id': 'src-4c677a33f142585f412bd332'})], + 'edges': [('edge-eb17ed8b418e07675647f859', {'edge_id': 'edge-eb17ed8b418e07675647f859', 'from_component_version_id': 'ver-45e5c3cd0ec04cedd2a6c9ff', 'optional': True, 'relationship': 'depends-on', 'resolver': 'python-manifest', 'scope': 'runtime', 'source_occurrence_id': 'occ-1bce1232778eebbe80ba4783', 'to_component_version_id': 'ver-5a2258d36e1f956f0c7bbad3'}), + ('edge-a13c4175a16beff87fab0f85', {'edge_id': 'edge-a13c4175a16beff87fab0f85', 'from_component_version_id': 'ver-45e5c3cd0ec04cedd2a6c9ff', 'metadata': {'marker': 'python_version < 3.15'}, 'optional': False, 'relationship': 'depends-on', 'resolver': 'python-manifest', 'scope': 'runtime', 'source_occurrence_id': 'occ-bac5af596371ff67bbb98d78', 'to_component_version_id': 'ver-c25c205dec3e1c5f0566706f'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "script-empty": "(None, {'sources': [], 'components': [], 'versions': [], 'occurrences': [], 'edges': [], 'extra_gaps': [], 'discovery_inputs': [], 'node_platforms': []})", + "script-ranged-pin": r"""(None, + {'sources': [('src-53a424fea65348bdb2b7a9e2', {'content_hash': 'sha256:d22d7204efefc07781701766eb556bda918c85f7e033c3fb0f71e64e266fd8cb', 'evidence_uri': 'app.py', 'metadata': {'evidence_class': 'repository'}, 'source_id': 'src-53a424fea65348bdb2b7a9e2', 'source_type': 'script-dependencies'})], + 'components': [('cmp-573ec625b75de401a754c4db', {'component_id': 'cmp-573ec625b75de401a754c4db', 'ecosystem': 'local', 'kind': 'automation-script', 'lifecycles': ['repository-used'], 'name': 'app.py', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), ('cmp-d80183028eb6e50b2f53021e', {'component_id': 'cmp-d80183028eb6e50b2f53021e', 'ecosystem': 'pypi', 'kind': 'library', 'lifecycles': ['repository-used'], 'name': 'pyyaml', 'namespace': '', 'official_channel_required': True, 'official_channels': [], 'purl': 'pkg:pypi/pyyaml'})], + 'versions': [('ver-29b1104305b017ea4508138a', {'component_id': 'cmp-573ec625b75de401a754c4db', 'component_version_id': 'ver-29b1104305b017ea4508138a', 'evidence': ['app.py'], 'resolution_state': 'resolved', 'source_ref': 'sha256:d22d7204efefc07781701766eb556bda918c85f7e033c3fb0f71e64e266fd8cb'}), ('ver-24ad8a8117694318538f56d4', {'component_id': 'cmp-d80183028eb6e50b2f53021e', 'component_version_id': 'ver-24ad8a8117694318538f56d4', 'constraint': '>=1.2.3', 'evidence': ['app.py#L1', 'app.py#line:1', 'requirements.txt#L1'], 'resolution_state': 'unresolved'})], + 'occurrences': [('occ-c995e71ae306b599a3aadeb9', {'component_id': 'cmp-d80183028eb6e50b2f53021e', 'component_version_id': 'ver-24ad8a8117694318538f56d4', 'dependency_scope': 'automation', 'directness': 'direct', 'evidence_locator': 'line:1', 'lifecycle': 'repository-used', 'metadata': {'distribution': 'PyYAML'}, 'occurrence_id': 'occ-c995e71ae306b599a3aadeb9', 'optional': False, 'raw_value': 'PyYAML>=1.2.3', 'role': 'script-direct-dependency', 'root_id': 'cmp-573ec625b75de401a754c4db', 'source_id': 'src-53a424fea65348bdb2b7a9e2'})], + 'edges': [('edge-c592494a40415813e7330b19', {'constraint': '>=1.2.3', 'edge_id': 'edge-c592494a40415813e7330b19', 'from_component_version_id': 'ver-29b1104305b017ea4508138a', 'metadata': {'distribution': 'PyYAML'}, 'optional': False, 'relationship': 'depends-on', 'resolver': 'sibling-python-requirements', 'scope': 'automation', 'source_occurrence_id': 'occ-c995e71ae306b599a3aadeb9', 'to_component_version_id': 'ver-24ad8a8117694318538f56d4'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "workflow-defaults": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-96798a62afd2f5a456064757', {'component_id': 'cmp-96798a62afd2f5a456064757', 'ecosystem': 'local', 'kind': 'fixture', 'lifecycles': ['repository-used'], 'name': 'input.json', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), ('cmp-9c5c40f09cf1dd84c78a24ef', {'component_id': 'cmp-9c5c40f09cf1dd84c78a24ef', 'ecosystem': 'npm', 'kind': 'node-project', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-b5e5f51f6ef2c47aceaed9ef', {'component_id': 'cmp-96798a62afd2f5a456064757', 'component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'evidence': ['input.json'], 'resolution_state': 'resolved', 'source_ref': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}), + ('ver-3df8ba0617b209e917509c74', {'component_id': 'cmp-9c5c40f09cf1dd84c78a24ef', 'component_version_id': 'ver-3df8ba0617b209e917509c74', 'evidence': ['package.json'], 'resolution_state': 'resolved', 'source_ref': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a'})], + 'occurrences': [('occ-517fd4f5effa81db9952a75c', {'component_id': 'cmp-9c5c40f09cf1dd84c78a24ef', 'component_version_id': 'ver-3df8ba0617b209e917509c74', 'dependency_scope': 'ci', 'directness': 'direct', 'evidence_locator': '/steps/0', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-517fd4f5effa81db9952a75c', 'optional': False, 'raw_value': 'npm install:./package.json', 'role': 'github-actions-manifest-install', 'root_id': 'cmp-96798a62afd2f5a456064757', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-975960de7c4b360eedcfd9cc', {'edge_id': 'edge-975960de7c4b360eedcfd9cc', 'from_component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'optional': False, 'relationship': 'installs-manifest', 'resolver': 'github-actions', 'scope': 'ci', 'source_occurrence_id': 'occ-517fd4f5effa81db9952a75c', 'to_component_version_id': 'ver-3df8ba0617b209e917509c74'})], + 'extra_gaps': [], + 'discovery_inputs': [], + 'node_platforms': []})""", + "workflow-bad-json": r"""(None, + {'sources': [('src-98a53e0ca7d133d11ccc09e7', {'content_hash': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'evidence_uri': 'input.json', 'source_id': 'src-98a53e0ca7d133d11ccc09e7', 'source_type': 'fixture'})], + 'components': [('cmp-96798a62afd2f5a456064757', {'component_id': 'cmp-96798a62afd2f5a456064757', 'ecosystem': 'local', 'kind': 'fixture', 'lifecycles': ['repository-used'], 'name': 'input.json', 'namespace': '', 'official_channel_required': False, 'official_channels': []}), ('cmp-9c5c40f09cf1dd84c78a24ef', {'component_id': 'cmp-9c5c40f09cf1dd84c78a24ef', 'ecosystem': 'npm', 'kind': 'node-project', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': []})], + 'versions': [('ver-b5e5f51f6ef2c47aceaed9ef', {'component_id': 'cmp-96798a62afd2f5a456064757', 'component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'evidence': ['input.json'], 'resolution_state': 'resolved', 'source_ref': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}), + ('ver-3df8ba0617b209e917509c74', {'component_id': 'cmp-9c5c40f09cf1dd84c78a24ef', 'component_version_id': 'ver-3df8ba0617b209e917509c74', 'evidence': ['package.json'], 'resolution_state': 'resolved', 'source_ref': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a'})], + 'occurrences': [('occ-517fd4f5effa81db9952a75c', {'component_id': 'cmp-9c5c40f09cf1dd84c78a24ef', 'component_version_id': 'ver-3df8ba0617b209e917509c74', 'dependency_scope': 'ci', 'directness': 'direct', 'evidence_locator': '/steps/0', 'lifecycle': 'repository-used', 'occurrence_id': 'occ-517fd4f5effa81db9952a75c', 'optional': False, 'raw_value': 'npm install:./package.json', 'role': 'github-actions-manifest-install', 'root_id': 'cmp-96798a62afd2f5a456064757', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'edges': [('edge-975960de7c4b360eedcfd9cc', {'edge_id': 'edge-975960de7c4b360eedcfd9cc', 'from_component_version_id': 'ver-b5e5f51f6ef2c47aceaed9ef', 'optional': False, 'relationship': 'installs-manifest', 'resolver': 'github-actions', 'scope': 'ci', 'source_occurrence_id': 'occ-517fd4f5effa81db9952a75c', 'to_component_version_id': 'ver-3df8ba0617b209e917509c74'})], + 'extra_gaps': [('gap-8e05074c2205cda994d10665', {'evidence': ['input.json#/steps/1'], 'gap_id': 'gap-8e05074c2205cda994d10665', 'gap_type': 'github-actions-install-manifest-unresolved', 'message': 'npm install at /steps/1 has no readable package.json in bad', 'source_id': 'src-98a53e0ca7d133d11ccc09e7'})], + 'discovery_inputs': [], + 'node_platforms': []})""", + "test_component_table_channel.1": r"""{'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'inferred', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['https://example.net/catalog', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'probe:200:https://example.org/app', 'research-pass:2'], + 'availability_state': 'available', + 'canonical_uri': 'https://example.org/app', + 'version_strategy': 'catalog-only', + 'gap': None}], + 'snapshots': [], + 'gaps': []}""", + "test_component_table_channel.2": r"""{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'unknown', + 'rights': None, + 'refresh_policy': 'policy-static', + 'discovery_method': 'inferred', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['https://example.net/catalog', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'probe:200:https://example.org/app', 'research-pass:2'], + 'availability_state': 'unresolved', + 'canonical_uri': None, + 'version_strategy': 'unresolved', + 'gap': {'state': 'unresolved', 'reason': 'catalog unavailable', 'blocking': False, 'evidence': ['https://example.net/catalog', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'probe:200:https://example.org/app', 'research-pass:2'], 'next_action': 'probe-wave'}}""", + "test_component_table_channel.3": r"""{'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'unknown', + 'rights': None, + 'refresh_policy': 'policy-static', + 'discovery_method': 'inferred', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['https://example.net/catalog', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'probe:200:https://example.org/app', 'research-pass:2'], + 'availability_state': 'unresolved', + 'canonical_uri': None, + 'version_strategy': 'unresolved', + 'gap': {'state': 'unresolved', 'reason': 'catalog unavailable', 'blocking': False, 'evidence': ['https://example.net/catalog', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'probe:200:https://example.org/app', 'research-pass:2'], 'next_action': 'probe-wave'}}], + 'snapshots': [], + 'gaps': []}""", + "table-unavailable": r"""{'channel_id': 'chn:fixture-policy:cmp-fixture:docs', + 'component_id': 'cmp-fixture', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'unknown', + 'rights': None, + 'refresh_policy': 'policy-static', + 'discovery_method': 'inferred', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['research-pass:None'], + 'availability_state': 'unavailable', + 'canonical_uri': None, + 'version_strategy': 'unresolved', + 'gap': {'state': 'unavailable', 'reason': '', 'blocking': False, 'evidence': ['policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'research-pass:None'], 'next_action': None}}""", + "table-explicit": "{'channel_id': 'chn:fixture-policy:cmp-fixture:docs', 'component_id': 'cmp-fixture', 'channel_type': 'docs', 'publisher': 'Example', 'access': 'restricted', 'rights': 'example terms', 'refresh_policy': 'on-version-change', 'discovery_method': 'inferred', 'confidence': 'high', 'review_state': 'accepted', 'evidence': ['fixture.json', 'probe:200:https://example.org/app', 'research-pass:3'], 'availability_state': 'available', 'canonical_uri': 'https://example.org/app', 'version_strategy': 'catalog-only', 'gap': None}", + "test_derived_channel.1": r"""{'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'available', + 'canonical_uri': 'https://example.org/app', + 'version_strategy': 'per-version', + 'gap': None}], + 'snapshots': [], + 'gaps': []}""", + "test_derived_channel.2": r"""{'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'unresolved', + 'canonical_uri': None, + 'version_strategy': 'unresolved', + 'gap': {'state': 'unresolved', 'reason': 'uri-template-unrenderable: https://example.org/{missing}', 'blocking': False, 'evidence': ['policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], 'next_action': 'probe-wave'}}], + 'snapshots': [], + 'gaps': []}""", + "test_derived_channel_cites_rendered_uri_in_gap.1": r"""{'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': None, 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'unknown', + 'rights': None, + 'refresh_policy': 'policy-static', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'unresolved', + 'canonical_uri': None, + 'version_strategy': 'unresolved', + 'gap': {'state': 'unresolved', 'reason': 'pending verification', 'blocking': False, 'evidence': ['derived-uri:https://example.org/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], 'next_action': 'probe-wave'}}], + 'snapshots': [], + 'gaps': []}""", + "derived-default": r"""{'channel_id': 'chn:fixture-policy:cmp-fixture:docs', + 'component_id': 'cmp-fixture', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'unknown', + 'rights': None, + 'refresh_policy': 'policy-static', + 'discovery_method': 'generated', + 'confidence': 'high', + 'review_state': 'accepted', + 'evidence': ['a', 'z'], + 'availability_state': 'unresolved', + 'canonical_uri': None, + 'version_strategy': 'unresolved', + 'gap': {'state': 'unresolved', 'reason': '', 'blocking': False, 'evidence': ['policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], 'next_action': None}}""", + "derived-explicit": r"""{'channel_id': 'chn:fixture-policy:cmp-fixture:docs', + 'component_id': 'cmp-fixture', + 'channel_type': 'docs', + 'publisher': 'Example', + 'access': 'restricted', + 'rights': 'example terms', + 'refresh_policy': 'on-version-change', + 'discovery_method': 'reviewed', + 'confidence': 'high', + 'review_state': 'accepted', + 'evidence': ['a', 'z'], + 'availability_state': 'unresolved', + 'canonical_uri': None, + 'version_strategy': 'catalog-only', + 'gap': {'state': 'unresolved', 'reason': 'pending', 'blocking': False, 'evidence': ['derived-uri:https://example.org/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], 'next_action': 'review'}}""", + "derived-explicit-available": "{'channel_id': 'chn:fixture-policy:cmp-fixture:docs', 'component_id': 'cmp-fixture', 'channel_type': 'docs', 'publisher': None, 'access': 'public', 'rights': None, 'refresh_policy': 'on-version-change', 'discovery_method': 'generated', 'confidence': 'high', 'review_state': 'accepted', 'evidence': ['a', 'z'], 'availability_state': 'available', 'canonical_uri': 'https://example.org/app', 'version_strategy': 'catalog-only', 'gap': None}", + "test_derived_component_record.1": r"""{'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'kind': 'library', 'ecosystem': 'pypi', 'namespace': 'example', 'name': 'app', 'aliases': [], 'purl': 'pkg:pypi/app', 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': 'widgets.example.org', 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'library', 'registry_identity': 'pkg:pypi/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-d25fa9e80d6b87b69c53aed9:docs', + 'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', + 'channel_type': 'docs', + 'publisher': None, + 'access': 'public', + 'rights': None, + 'refresh_policy': 'on-version-change', + 'discovery_method': 'generated', + 'confidence': 'medium', + 'review_state': 'accepted', + 'evidence': ['input.json', 'live-export:fixture.json#/items/0', 'pkg:pypi/app', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], + 'availability_state': 'available', + 'canonical_uri': 'live-export:fixture.json#/items/0', + 'version_strategy': 'per-version', + 'gap': None}], + 'snapshots': [], + 'gaps': []}""", + "derived-component-defaults": r"""{'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-fixture', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-fixture', 'kind': 'package', 'ecosystem': 'unknown', 'namespace': None, 'name': 'cmp-fixture', 'aliases': [], 'purl': None, 'cpe': None, 'oci_repository': None, 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': '', 'registry_identity': 'example/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [], + 'snapshots': [], + 'gaps': []}""", + "derived-component-oci": r"""{'$schema': 'https://github.com/cordanaLLM/knowledge/schemas/registry/component-record-v1.1.schema.json', + 'schema_version': '1.1.0', + 'record_kind': 'reviewed_component', + 'record_id': 'record:fixture-policy:cmp-fixture', + 'review': {'status': 'accepted', 'reviewed_by': 'channel-policy:fixture-policy@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'reviewed_at': '2026-01-02T03:04:05Z', 'evidence': ['baseline:baseline', 'policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']}, + 'component': {'component_id': 'cmp-fixture', 'kind': 'image', 'ecosystem': 'oci', 'namespace': None, 'name': 'cmp-fixture', 'aliases': [], 'purl': None, 'cpe': None, 'oci_repository': 'example/app', 'chart_repository': None, 'chart_name': None, 'api_group': None, 'gvk': [], 'source_repo': None, 'lifecycle': 'deployed', 'disposition': 'selected', 'owners': [], 'topics': [], 'authority_policy': 'channel-policy-delegated-acceptance', 'created_at': '2026-01-02T03:04:05Z', 'registry_kind': 'image', 'registry_identity': 'example/app'}, + 'versions': [], + 'occurrences': [], + 'dependencies': [], + 'channels': [{'channel_id': 'chn:fixture-policy:cmp-fixture:docs', 'component_id': 'cmp-fixture', 'channel_type': 'docs', 'publisher': None, 'access': 'public', 'rights': None, 'refresh_policy': 'on-version-change', 'discovery_method': 'generated', 'confidence': 'medium', 'review_state': 'accepted', 'evidence': ['policy.json@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], 'availability_state': 'available', 'canonical_uri': 'https://example.org/app', 'version_strategy': 'per-version', 'gap': None}], + 'snapshots': [], + 'gaps': []}""", + "test_snapshot_reviewed_version_entry.1": "{'component_version_id': 'ver-fixture', 'component_id': 'cmp-fixture', 'purl': None, 'constraint': '^1.2.0', 'resolved_version': '1.2.3', 'source_ref': None, 'artifact_digest': 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'platform': 'linux/amd64', 'build_metadata': {}, 'release_time': None, 'observed_at': '2026-01-02T03:04:05Z', 'valid_from': None, 'valid_to': None, 'resolution_state': 'resolved', 'evidence': ['a.json', 'z.json']}", + "test_snapshot_reviewed_version_entry.2": "None", + "snapshot-missing-version": "None", + "snapshot-invalid-state": "None", + "snapshot-no-evidence": "None", + "snapshot-no-time": "None", + "snapshot-mutable-only": "None", + "snapshot-mutable-version": "None", + "snapshot-mutable-source": "None", + "snapshot-invalid-digest": "None", + "snapshot-invalid-platform": "{'component_version_id': 'ver-example', 'component_id': 'cmp-fixture', 'purl': None, 'constraint': None, 'resolved_version': '1.2.3', 'source_ref': None, 'artifact_digest': None, 'platform': 'linux/unknown', 'build_metadata': {}, 'release_time': None, 'observed_at': '2026-01-02T03:04:05Z', 'valid_from': None, 'valid_to': None, 'resolution_state': 'resolved', 'evidence': ['input.json']}", + "snapshot-nonstr-platform": "None", + "snapshot-ref-only": "{'component_version_id': 'ver-example', 'component_id': 'cmp-fixture', 'purl': None, 'constraint': None, 'resolved_version': None, 'source_ref': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', 'artifact_digest': None, 'platform': None, 'build_metadata': {}, 'release_time': None, 'observed_at': '2026-01-02T03:04:05Z', 'valid_from': None, 'valid_to': None, 'resolution_state': 'resolved', 'evidence': ['input.json']}", + "snapshot-partial": "{'component_version_id': 'ver-example', 'component_id': 'cmp-fixture', 'purl': None, 'constraint': '>=1.2.3', 'resolved_version': None, 'source_ref': None, 'artifact_digest': None, 'platform': None, 'build_metadata': {}, 'release_time': None, 'observed_at': '2026-01-02T03:04:05Z', 'valid_from': None, 'valid_to': None, 'resolution_state': 'partial', 'evidence': ['input.json']}", + "test_merge_manifests.1": r"""{'$schema': 'https://json-schema.org/draft/2020-12/schema', + 'authority_boundary': {'review_state': 'unreviewed', 'authoritative': False, 'compile_eligible': False, 'promote_eligible': False, 'source_admission': False, 'retrieval_release': False, 'production_mutation': False}, + 'base_manifest_id': 'mft-564b17732570c05c12a354b74b50759db334055f472df198bd3f05c96f742667', + 'bounds': {'components': 100000, 'dependency_edges': 700000, 'discovery_file_bytes': 8388608, 'discovery_files': 10000, 'discovery_total_bytes': 134217728, 'gaps': 400000, 'json_depth': 128, 'json_input_bytes': 805306368, 'json_nodes': 20000000, 'occurrences': 400000, 'serialized_output_bytes': 805306368, 'sources': 100000, 'tracked_files': 20000, 'versions': 200000}, + 'completeness': {'input': {'state': 'unknown', 'input_count': 0, 'blocking_input_ids': []}, 'enumeration': {'state': 'unknown'}, 'closure': {'state': 'unknown', 'blocking_gap_ids': []}, 'identity': {'state': 'complete', 'blocking_gap_ids': []}, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots': {'state': 'unknown', 'accepted_available_channels': 0, 'immutable_verified_channels': 0, 'missing_channel_ids': []}, 'all_axes_complete': False}, + 'components': [{'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'ecosystem': 'pypi', 'kind': 'library', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': [], 'purl': 'pkg:pypi/app'}], + 'counts': {'sources': 0, 'components': 1, 'versions': 1, 'occurrences': 0, 'dependency_edges': 0, 'gaps': 0}, + 'dependency_edges': [], + 'gaps': [], + 'generation_state': 'candidate', + 'generator': {'name': 'knowledge-registry', 'ruleset_hash': 'sha256:e49f3c59e9a4f697b953166bd42e04ef0cf1a9838299fc2fd7168dc4418aa909', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'source_ref': 'tools/knowledge-registry/knowledge_registry.py#sha256:932e46cc7a68437ad6cb5eba1c8609a78d800806d8a082771807c124b2bdb6bc', 'version': '2'}, + 'input_set': {'entries': [], 'required_source_classes': []}, + 'integrity': {'canonicalization': 'archeion-canonical-json-v1', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'deterministic_order': True, 'exact_counts': {'sources': 0, 'components': 1, 'versions': 1, 'occurrences': 0, 'dependency_edges': 0, 'gaps': 0}, 'manifest_hash': 'sha256:0b65a7435fc8cba72650ef237a38d77c439dfa6a4539e2bdc2dfae47b233e5d8'}, + 'manifest_version': 2, + 'merge_lineage': {'current_manifest_id': 'mft-8a9d3794734c151de06d1d385556317501e6b79489abed0c902e49ecf764688c', 'input_manifest_ids': ['mft-564b17732570c05c12a354b74b50759db334055f472df198bd3f05c96f742667', 'mft-8a9d3794734c151de06d1d385556317501e6b79489abed0c902e49ecf764688c'], 'previous_manifest_id': 'mft-564b17732570c05c12a354b74b50759db334055f472df198bd3f05c96f742667', 'selection_policy': 'latest-observed-at-then-manifest-id-v1'}, + 'observation': {'observed_at': '2026-01-02T03:04:06Z', 'source_valid_at': '2026-01-02T03:04:05Z', 'source_valid_time_basis': 'git-commit-committer-time'}, + 'occurrences': [], + 'reconciliation': {'previous_manifest_id': 'mft-564b17732570c05c12a354b74b50759db334055f472df198bd3f05c96f742667', 'complete_mark': False, 'removal_allowed': False, 'added': [], 'changed': [], 'missing': [], 'removed': []}, + 'record_kind': 'generated_discovery_manifest', + 'schema_version': '2.0.0', + 'sources': [], + 'versions': [{'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'component_version_id': 'ver-30de7421b28e93364d3ed079', 'evidence': ['input.json', 'other.json'], 'resolution_state': 'resolved', 'resolved_version': '1.2.3'}], + 'manifest_id': 'mft-0b65a7435fc8cba72650ef237a38d77c439dfa6a4539e2bdc2dfae47b233e5d8'}""", + "test_merge_manifests.2": r"""{'$schema': 'https://json-schema.org/draft/2020-12/schema', + 'authority_boundary': {'review_state': 'unreviewed', 'authoritative': False, 'compile_eligible': False, 'promote_eligible': False, 'source_admission': False, 'retrieval_release': False, 'production_mutation': False}, + 'base_manifest_id': 'mft-564b17732570c05c12a354b74b50759db334055f472df198bd3f05c96f742667', + 'bounds': {'components': 100000, 'dependency_edges': 700000, 'discovery_file_bytes': 8388608, 'discovery_files': 10000, 'discovery_total_bytes': 134217728, 'gaps': 400000, 'json_depth': 128, 'json_input_bytes': 805306368, 'json_nodes': 20000000, 'occurrences': 400000, 'serialized_output_bytes': 805306368, 'sources': 100000, 'tracked_files': 20000, 'versions': 200000}, + 'completeness': {'input': {'state': 'unknown', 'input_count': 0, 'blocking_input_ids': []}, 'enumeration': {'state': 'unknown'}, 'closure': {'state': 'unknown', 'blocking_gap_ids': []}, 'identity': {'state': 'complete', 'blocking_gap_ids': []}, 'channel_review': {'state': 'complete', 'required_slots': 0, 'accepted_slots': 0}, 'snapshots': {'state': 'unknown', 'accepted_available_channels': 0, 'immutable_verified_channels': 0, 'missing_channel_ids': []}, 'all_axes_complete': False}, + 'components': [{'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'ecosystem': 'pypi', 'kind': 'library', 'lifecycles': ['repository-used'], 'name': 'app', 'namespace': '', 'official_channel_required': False, 'official_channels': [], 'purl': 'pkg:pypi/app'}], + 'counts': {'sources': 0, 'components': 1, 'versions': 1, 'occurrences': 0, 'dependency_edges': 0, 'gaps': 0}, + 'dependency_edges': [], + 'gaps': [], + 'generation_state': 'candidate', + 'generator': {'name': 'knowledge-registry', 'ruleset_hash': 'sha256:e49f3c59e9a4f697b953166bd42e04ef0cf1a9838299fc2fd7168dc4418aa909', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'source_ref': 'tools/knowledge-registry/knowledge_registry.py#sha256:932e46cc7a68437ad6cb5eba1c8609a78d800806d8a082771807c124b2bdb6bc', 'version': '2'}, + 'input_set': {'entries': [], 'required_source_classes': []}, + 'integrity': {'canonicalization': 'archeion-canonical-json-v1', 'schema_hash': 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', 'deterministic_order': True, 'exact_counts': {'sources': 0, 'components': 1, 'versions': 1, 'occurrences': 0, 'dependency_edges': 0, 'gaps': 0}, 'manifest_hash': 'sha256:0b65a7435fc8cba72650ef237a38d77c439dfa6a4539e2bdc2dfae47b233e5d8'}, + 'manifest_version': 2, + 'merge_lineage': {'current_manifest_id': 'mft-8a9d3794734c151de06d1d385556317501e6b79489abed0c902e49ecf764688c', 'input_manifest_ids': ['mft-564b17732570c05c12a354b74b50759db334055f472df198bd3f05c96f742667', 'mft-8a9d3794734c151de06d1d385556317501e6b79489abed0c902e49ecf764688c'], 'previous_manifest_id': 'mft-564b17732570c05c12a354b74b50759db334055f472df198bd3f05c96f742667', 'selection_policy': 'latest-observed-at-then-manifest-id-v1'}, + 'observation': {'observed_at': '2026-01-02T03:04:06Z', 'source_valid_at': '2026-01-02T03:04:05Z', 'source_valid_time_basis': 'git-commit-committer-time'}, + 'occurrences': [], + 'reconciliation': {'previous_manifest_id': 'mft-564b17732570c05c12a354b74b50759db334055f472df198bd3f05c96f742667', 'complete_mark': False, 'removal_allowed': False, 'added': [], 'changed': [], 'missing': [], 'removed': []}, + 'record_kind': 'generated_discovery_manifest', + 'schema_version': '2.0.0', + 'sources': [], + 'versions': [{'component_id': 'cmp-d25fa9e80d6b87b69c53aed9', 'component_version_id': 'ver-30de7421b28e93364d3ed079', 'evidence': ['input.json', 'other.json'], 'resolution_state': 'resolved', 'resolved_version': '1.2.3'}], + 'manifest_id': 'mft-0b65a7435fc8cba72650ef237a38d77c439dfa6a4539e2bdc2dfae47b233e5d8'}""", + "test_merge_manifests.3": "('RegistryInputError', 'merge requires at least one candidate manifest')", + "test_merge_manifests.4": "('RegistryInputError', 'merge input 1 is invalid: schema_version must equal 2.0.0')", + "test_strict_merge_candidate_record_combines_lifecycles.1": "{'lifecycles': ['deployed', 'repository-used']}", + "test_strict_merge_candidate_value.1": "{'evidence': ['a.json', 'b.json', 'z.json'], 'metadata': {'observed_at': '2026-01-02T03:04:06Z'}, 'source_ref': '1.2.3'}", + "test_strict_merge_candidate_value.2": "{'evidence': ['a.json', 'b.json', 'z.json'], 'metadata': {'observed_at': '2026-01-02T03:04:06Z'}, 'source_ref': '1.2.3'}", + "test_strict_merge_candidate_value.3": "('RegistryInputError', 'merge conflict for versions record ver-fixture at /source_ref')", +} + + +class ChannelRecordTests(unittest.TestCase): + """Build reviewed channel and version records from in-memory policies.""" + + def test_derived_channel(self) -> None: + """Render available template channels and degrade unresolved templates.""" + builder, component, _ = package_builder() + entry = policy_entry("https://example.org/{name}") + check_output( + self, + EXPECTED, + "test_derived_channel.1", + kr.derived_component_record, + entry, + builder.components[component], + "pkg:pypi/app", + "baseline", + None, + ) + + entry["record"]["channels"][0]["uri_template"] = "https://example.org/{missing}" + check_output( + self, + EXPECTED, + "test_derived_channel.2", + kr.derived_component_record, + entry, + builder.components[component], + "pkg:pypi/app", + "baseline", + None, + ) + + def test_derived_channel_cites_rendered_uri_in_gap(self) -> None: + """Cite a renderable URI that still needs verification.""" + builder, component, _ = package_builder() + entry = policy_entry("https://example.org/{name}") + spec = entry["record"]["channels"][0] + spec.update( + disposition="derived-unverified", + gap_reason="pending verification", + ) + check_output( + self, + EXPECTED, + "test_derived_channel_cites_rendered_uri_in_gap.1", + kr.derived_component_record, + entry, + builder.components[component], + "pkg:pypi/app", + "baseline", + None, + ) + + def test_component_table_channel(self) -> None: + """Carry catalog provenance into available channels and explicit gaps.""" + builder, component, _ = package_builder() + entry = policy_entry() + entry["record"]["tables"] = { + kr.CHANNEL_POLICY_PROVENANCE_TABLE: { + "fixture": "https://example.net/catalog" + }, + } + row = { + "channel_type": kr.OFFICIAL_CHANNEL_TYPES[0], + "disposition": "available", + "canonical_uri": CHANNEL_URI, + "provenance": {"pass": "2", "refs": ["fixture", "missing"]}, + "probe": {"status": 200, "final_url": CHANNEL_URI}, + } + check_output( + self, + EXPECTED, + "test_component_table_channel.1", + kr.derived_component_record, + entry, + builder.components[component], + "pkg:pypi/app", + "baseline", + None, + row_set={"channels": [row]}, + ) + + row.update(disposition="unresolved", reason="catalog unavailable") + check_output( + self, + EXPECTED, + "test_component_table_channel.2", + kr._component_table_channel, + entry, + row, + component, + [entry["citation"]], + ) + check_output( + self, + EXPECTED, + "test_component_table_channel.3", + kr.derived_component_record, + entry, + builder.components[component], + "pkg:pypi/app", + "baseline", + None, + row_set={"channels": [row]}, + ) + + def test_derived_component_record(self) -> None: + """Stamp the policy and preserve the exact pointer in evidence templates.""" + builder, component, _ = package_builder() + entry = policy_entry("{evidence}") + live_pointer = "live-export:fixture.json#/items/0" + component_row = { + **builder.components[component], + "namespace": "example", + "metadata": {"api_group": "widgets.example.org"}, + } + check_output( + self, + EXPECTED, + "test_derived_component_record.1", + kr.derived_component_record, + entry, + component_row, + "pkg:pypi/app", + "baseline", + "input.json", + live_pointer, + ) + + def test_snapshot_reviewed_version_entry(self) -> None: + """Skip digestless resolved images and select the next expressible version.""" + component = "cmp-fixture" + version = { + "component_version_id": "ver-fixture", + "resolution_state": "resolved", + "resolved_version": "1.2.3", + "constraint": "^1.2.0", + "artifact_digest": DIGEST, + "platform": "linux/amd64", + "evidence": ["z.json", "a.json", "a.json"], + "metadata": {"observed_at": "invalid"}, + } + check_output( + self, + EXPECTED, + "test_snapshot_reviewed_version_entry.1", + kr.snapshot_reviewed_version_entry, + component, + [ + {**version, "component_version_id": "ver-later"}, + { + **version, + "component_version_id": "ver-earlier", + "artifact_digest": None, + }, + version, + ], + OBSERVED, + ecosystem="oci", + kind="image", + ) + check_output( + self, + EXPECTED, + "test_snapshot_reviewed_version_entry.2", + kr.snapshot_reviewed_version_entry, + component, + [{**version, "artifact_digest": None}], + OBSERVED, + ecosystem="oci", + kind="image", + ) + + def test_derived_channel_explicit_and_unresolved_specs(self) -> None: + """Retain explicit policy settings and apply defaults for unresolved channels.""" + entry = policy_entry() + base = entry["record"]["channels"][0] + for label, spec in ( + ( + "derived-default", + {"channel_type": base["channel_type"], "disposition": "unresolved"}, + ), + ( + "derived-explicit", + { + **base, + "access": "restricted", + "publisher": "Example", + "rights": "example terms", + "refresh_policy": "on-version-change", + "discovery_method": "reviewed", + "confidence": "high", + "version_strategy": "catalog-only", + "next_action": "review", + "disposition": "derived-unverified", + "gap_reason": "pending", + }, + ), + ( + "derived-explicit-available", + { + **base, + "version_strategy": "catalog-only", + "confidence": "high", + }, + ), + ): + check_output( + self, + EXPECTED, + label, + kr._derived_channel, + entry, + spec, + "cmp-fixture", + {}, + ["z", "a", "a"], + ) + + def test_component_table_channel_defaults_and_overrides(self) -> None: + """Handle missing provenance, explicit fields, and unavailable rows.""" + entry = policy_entry() + row = { + "channel_type": kr.OFFICIAL_CHANNEL_TYPES[0], + "disposition": "unavailable", + } + check_output( + self, + EXPECTED, + "table-unavailable", + kr._component_table_channel, + entry, + row, + "cmp-fixture", + [], + ) + row.update( + disposition="available", + canonical_uri=CHANNEL_URI, + access="restricted", + publisher="Example", + rights="example terms", + confidence="high", + provenance={"pass": 3, "refs": []}, + probe={"status": 200, "final_url": CHANNEL_URI}, + ) + check_output( + self, + EXPECTED, + "table-explicit", + kr._component_table_channel, + entry, + row, + "cmp-fixture", + ["fixture.json"], + ) + + def test_derived_component_record_defaults(self) -> None: + """Use the component ID and unknown ecosystem when optional fields are absent.""" + entry = policy_entry() + entry["record"]["channels"] = [] + check_output( + self, + EXPECTED, + "derived-component-defaults", + kr.derived_component_record, + entry, + {"component_id": "cmp-fixture"}, + "example/app", + "baseline", + None, + ) + entry["record"]["channels"] = policy_entry()["record"]["channels"] + check_output( + self, + EXPECTED, + "derived-component-oci", + kr.derived_component_record, + entry, + { + "component_id": "cmp-fixture", + "kind": "image", + "ecosystem": "oci", + "metadata": {"oci_repository": "example/app"}, + }, + "example/app", + "baseline", + None, + ) + + def test_snapshot_reviewed_version_entry_rejects_unexpressible_rows(self) -> None: + """Skip versions that lack valid identity, time, digest, or platform.""" + row = { + "component_version_id": "ver-example", + "resolution_state": "resolved", + "resolved_version": "1.2.3", + "evidence": ["input.json"], + "metadata": {"observed_at": OBSERVED}, + } + for label, invalid in ( + ("snapshot-missing-version", {**row, "component_version_id": ""}), + ("snapshot-invalid-state", {**row, "resolution_state": "invalid"}), + ("snapshot-no-evidence", {**row, "evidence": [None, ""]}), + ("snapshot-no-time", {**row, "metadata": None}), + ( + "snapshot-mutable-only", + {**row, "resolved_version": None, "source_ref": "main"}, + ), + ("snapshot-mutable-version", {**row, "resolved_version": "main"}), + ("snapshot-mutable-source", {**row, "source_ref": "main"}), + ("snapshot-invalid-digest", {**row, "artifact_digest": "invalid"}), + ("snapshot-invalid-platform", {**row, "platform": "linux/unknown"}), + ("snapshot-nonstr-platform", {**row, "platform": 42}), + ): + check_output( + self, + EXPECTED, + label, + kr.snapshot_reviewed_version_entry, + "cmp-fixture", + [None, invalid], + None, + ecosystem="pypi", + kind="library", + ) + + def test_snapshot_reviewed_version_entry_supports_ref_and_partial(self) -> None: + """Copy an immutable source ref or an explicitly unresolved constraint.""" + row = { + "component_version_id": "ver-example", + "resolution_state": "resolved", + "source_ref": "b" * 40, + "evidence": ["input.json"], + "metadata": {"observed_at": OBSERVED}, + } + check_output( + self, + EXPECTED, + "snapshot-ref-only", + kr.snapshot_reviewed_version_entry, + "cmp-fixture", + [row], + LATER, + ecosystem="git", + kind="git-repository", + ) + row.update(resolution_state="partial", constraint=">=1.2.3", source_ref=None) + check_output( + self, + EXPECTED, + "snapshot-partial", + kr.snapshot_reviewed_version_entry, + "cmp-fixture", + [row], + LATER, + ecosystem="pypi", + kind="library", + ) + + +class MergeTests(ManifestFixtureTestCase): + """Build manifest candidates and conflicting records for strict merges.""" + + def test_strict_merge_candidate_value(self) -> None: + """Union evidence and keep the latest timestamp while rejecting scalar conflicts.""" + left = { + "evidence": ["z.json", "a.json"], + "metadata": {"observed_at": LATER}, + "source_ref": "1.2.3", + } + right = { + "evidence": ["b.json", "a.json"], + "metadata": {"observed_at": OBSERVED}, + "source_ref": "1.2.3", + } + check_output( + self, + EXPECTED, + "test_strict_merge_candidate_value.1", + kr.strict_merge_candidate_record, + "versions", + "ver-fixture", + left, + right, + ) + check_output( + self, + EXPECTED, + "test_strict_merge_candidate_value.2", + kr.strict_merge_candidate_record, + "versions", + "ver-fixture", + right, + left, + ) + with self.assertRaisesRegex( + kr.RegistryInputError, + "merge conflict for versions record ver-fixture at /source_ref", + ): + check_output( + self, + EXPECTED, + "test_strict_merge_candidate_value.3", + kr.strict_merge_candidate_record, + "versions", + "ver-fixture", + left, + {**right, "source_ref": "1.2.4"}, + ) + + def test_strict_merge_candidate_record_combines_lifecycles(self) -> None: + """Union distinct lifecycle entries for the same component.""" + check_output( + self, + EXPECTED, + "test_strict_merge_candidate_record_combines_lifecycles.1", + kr.strict_merge_candidate_record, + "components", + "cmp-fixture", + {"lifecycles": ["repository-used"]}, + {"lifecycles": ["deployed"]}, + ) + + def test_merge_manifests(self) -> None: + """Produce deterministic merged evidence and lineage from temporal candidates.""" + builder, component, _version = package_builder(required=False) + older = kr.seal_manifest( + { + **builder.manifest(), + "observation": { + "observed_at": OBSERVED, + "source_valid_at": OBSERVED, + "source_valid_time_basis": "git-commit-committer-time", + }, + } + ) + builder.add_version( + component, resolved_version="1.2.3", evidence=("other.json",) + ) + newer = kr.seal_manifest( + { + **builder.manifest(base_manifest_id=older["manifest_id"]), + "observation": {**older["observation"], "observed_at": LATER}, + } + ) + check_output( + self, EXPECTED, "test_merge_manifests.1", kr.merge_manifests, [newer, older] + ) + check_output( + self, EXPECTED, "test_merge_manifests.2", kr.merge_manifests, [older, newer] + ) + with self.assertRaisesRegex( + kr.RegistryInputError, "merge requires at least one candidate manifest" + ): + check_output( + self, EXPECTED, "test_merge_manifests.3", kr.merge_manifests, [] + ) + with self.assertRaisesRegex( + kr.RegistryInputError, "merge input 1 is invalid: schema_version must equal" + ): + check_output( + self, + EXPECTED, + "test_merge_manifests.4", + kr.merge_manifests, + [older, {**newer, "schema_version": "invalid"}], + ) + + +class CommandTests(FilesTestCase): + """Build temporary CLI paths and capture registry and live helper output.""" + + def test_capture_live_main(self) -> None: + """Reject a non-UTC observation time before capture opens any inputs.""" + output = self.root / "capture" + args = [ + "--output-dir", + str(output), + "--kubeconfig", + str(self.root / "unused.yaml"), + "--git-commit", + "a" * 40, + "--observed-at", + "2026-01-02", + ] + with ( + redirect_stdout(io.StringIO()) as stdout, + redirect_stderr(io.StringIO()) as stderr, + ): + result = live.main(args) + self.assertEqual( + (result, stdout.getvalue(), stderr.getvalue(), list(self.root.iterdir())), + (2, "", "capture failed: observed-at must be an exact UTC second\n", []), + ) + + def test_capture_live_main_result_states(self) -> None: + """Report incomplete capture with exit one and complete capture with exit zero.""" + args = [ + "--output-dir", + str(self.root / "capture"), + "--kubeconfig", + str(self.root / "unused.yaml"), + "--git-commit", + "a" * 40, + "--observed-at", + OBSERVED, + ] + for state, code in (("complete", 0), ("incomplete", 1)): + with ( + patch.object(live, "capture", return_value={"state": state}), + redirect_stdout(io.StringIO()) as stdout, + redirect_stderr(io.StringIO()) as stderr, + ): + result = live.main(args) + self.assertEqual( + ( + result, + stdout.getvalue(), + stderr.getvalue(), + list(self.root.iterdir()), + ), + (code, f'{{\n "state": "{state}"\n}}\n', "", []), + ) + + def run_registry( + self, args: list[str], output: Path | None = None + ) -> tuple[int, str, str, Record | None]: + """Read complete CLI streams and the parsed output document.""" + raw_stdout = io.BytesIO() + with ( + redirect_stdout( + io.TextIOWrapper(raw_stdout, encoding="utf-8", write_through=True) + ) as stdout, + redirect_stderr(io.StringIO()) as stderr, + ): + result = kr.main(args) + stdout.flush() + text = raw_stdout.getvalue().decode() + written = ( + json.loads(output.read_text()) + if output is not None and output.is_file() + else None + ) + return result, text, stderr.getvalue(), written + + def test_main_gaps(self) -> None: + """Return success with the complete printed gap report.""" + input_path = self.write("manifest.json", '{"gaps":[{"gap_id":"example"}]}') + with ( + patch.object(kr, "registry_generator_source_binding", return_value={}), + patch.object(kr, "validate_manifest", return_value=[]), + ): + self.assertEqual( + self.run_registry(["gaps", str(input_path)]), + (0, '{"count":1,"gaps":[{"gap_id":"example"}]}\n', "", None), + ) + + def test_main(self) -> None: + """Write canonical capabilities once and refuse an existing output file.""" + output = self.root / "capabilities.json" + args = ["capabilities", "--output", str(output)] + expected = { + "allowed": [ + "discover-repo", + "import-live", + "import-reviewed", + "merge", + "derive-channels", + "bind-identity", + "bind-oci-identity", + "wave-gate", + "snapshot-gate", + "identity-gate", + "validate", + "summarize", + "coverage", + "gaps", + ], + "network_access": False, + "cluster_access": "read-only capture helper only", + "source_acquisition": False, + "source_admission": False, + "retrieval_release": False, + "signing": False, + "pointer_mutation": False, + "production_mutation": False, + } + self.assertEqual(self.run_registry(args, output), (0, "", "", expected)) + error = FileExistsError(errno.EEXIST, os.strerror(errno.EEXIST), str(output)) + self.assertEqual( + self.run_registry(args, output), + ( + 2, + "", + f"knowledge-registry: output must be a fresh non-symlink file: {output}: {error}\n", + expected, + ), + ) + + def test_main_report_dispatch(self) -> None: + """Write either a complete summary or the coverage result from its offline handler.""" + manifest = {"manifest_id": "example", "authority_boundary": {"network": False}} + input_path = self.write("manifest.json", json.dumps(manifest)) + with ( + patch.object(kr, "registry_generator_source_binding", return_value={}), + patch.object(kr, "validate_manifest", return_value=[]), + patch.object(kr, "manifest_is_complete", return_value=True), + patch.object(kr, "summarize_manifest", return_value={"kind": "summary"}), + patch.object(kr, "coverage_manifest", return_value={"kind": "coverage"}), + ): + self.assertEqual( + self.run_registry(["summarize", str(input_path)]), + ( + 0, + '{"authority_boundary":{"network":false},"complete":true,"kind":"summary","manifest_id":"example"}\n', + "", + None, + ), + ) + self.assertEqual( + self.run_registry(["coverage", str(input_path)]), + ( + 0, + '{"kind":"coverage"}\n', + "", + None, + ), + ) + + def test_main_validate_reports_incomplete_and_invalid(self) -> None: + """Return the validation report and a failure exit for an incomplete manifest.""" + input_path = self.write("manifest.json", "{}") + output = self.root / "validate.json" + with ( + patch.object(kr, "registry_generator_source_binding", return_value={}), + patch.object(kr, "validate_manifest", return_value=["fixture error"]), + patch.object(kr, "manifest_is_complete", return_value=False), + patch.object(kr, "counts_for", return_value={"components": 0}), + ): + self.assertEqual( + self.run_registry( + [ + "validate", + str(input_path), + "--require-complete", + "--allow-unsorted", + "-o", + str(output), + ], + output, + ), + ( + 1, + "", + "", + { + "valid": False, + "complete": False, + "counts": {"components": 0}, + "errors": [ + "candidate is explicitly incomplete", + "fixture error", + ], + }, + ), + ) + + def test_main_rejects_multiple_stdin_inputs(self) -> None: + """Refuse duplicate stdin before calling any import handler.""" + refused = AssertionError("duplicate stdin reached the import handler") + with ( + patch.object(kr, "registry_generator_source_binding", return_value={}), + patch.object(kr, "import_live", side_effect=refused), + patch.object(kr, "import_reviewed", side_effect=refused), + patch.object(kr, "merge_input_files", side_effect=refused), + ): + for args in ( + ["import-live", "-", "--capture-manifest", "-"], + ["import-reviewed", "-", "-"], + ["merge", "-", "-"], + ): + self.assertEqual( + self.run_registry(args), + ( + 2, + "", + "knowledge-registry: stdin may only be specified once\n", + None, + ), + ) + + def test_main_candidate_dispatch(self) -> None: + """Dispatch each candidate command offline and preserve its complete result.""" + manifest = {"manifest_id": "example"} + path = str(self.root) + commands = ( + (["discover-repo", path, "--observed-at", OBSERVED], "discover_repo"), + (["import-live", path], "import_live"), + (["import-reviewed", path], "import_reviewed"), + (["merge", path], "merge_input_files"), + ) + with ( + patch.object(kr, "registry_generator_source_binding", return_value={}), + patch.object(kr, "validate_manifest", return_value=[]), + patch.object(kr, "manifest_is_complete", return_value=False), + ExitStack() as stack, + ): + for _, handler in commands: + stack.enter_context(patch.object(kr, handler, return_value=manifest)) + for args, handler in commands: + with self.subTest(handler=handler): + expected = '{"manifest_id":"example"}\n' + self.assertEqual(self.run_registry(args), (0, expected, "", None)) + self.assertEqual( + self.run_registry([*args, "--require-complete"]), + (1, expected, "", None), + ) + + def test_main_gate_dispatch(self) -> None: + """Map complete gate reports to exit status and preserve the output.""" + path = str(self.write("manifest.json", "{}")) + directory = str(self.root) + cases = ( + (["wave-gate", path, path, "--policies", directory], "channel_wave_gate"), + ( + ["snapshot-gate", path, path, "--receipts", directory], + "channel_snapshot_gate", + ), + (["identity-gate", path, path, "--receipts", directory], "identity_gate"), + ) + with ( + patch.object(kr, "registry_generator_source_binding", return_value={}), + patch.object(kr, "load_channel_policies", return_value=[]), + ExitStack() as stack, + ): + gates = { + handler: stack.enter_context(patch.object(kr, handler)) + for _, handler in cases + } + for args, handler in cases: + with self.subTest(handler=handler): + gates[handler].return_value = {"pass": True} + self.assertEqual( + self.run_registry(args), (0, '{"pass":true}\n', "", None) + ) + gates[handler].return_value = {"pass": False} + self.assertEqual( + self.run_registry(args), (1, '{"pass":false}\n', "", None) + ) + + def test_main_binds_identity_and_plans_oci(self) -> None: + """Write every identity binding output and the unbound OCI plan.""" + path = str(self.write("manifest.json", '{"manifest_id":"example"}')) + report = self.root / "identity.json" + arguments = [path, "--receipts", str(self.root), "--output", str(report)] + fragment = {"manifest_id": "fixture-fragment"} + with ( + patch.object(kr, "registry_generator_source_binding", return_value={}), + patch.object(kr, "validate_manifest", return_value=[]), + patch.object( + kr, "bind_gitops_identity", return_value=(fragment, {"kind": "git"}) + ), + patch.object( + kr, "bind_oci_identity", return_value=(fragment, {"kind": "oci"}) + ), + patch.object( + kr, + "oci_identity_plan", + return_value=([{"reference": "example/app"}], [{"reason": "missing"}]), + ), + ): + self.assertEqual( + self.run_registry(["bind-identity", *arguments], report), + ( + 0, + '{"kind":"git"}\n', + "", + {"manifest_id": "fixture-fragment"}, + ), + ) + report.unlink() + self.assertEqual( + self.run_registry(["bind-oci-identity", *arguments], report), + ( + 0, + '{"kind":"oci"}\n', + "", + {"manifest_id": "fixture-fragment"}, + ), + ) + report.unlink() + self.assertEqual( + self.run_registry( + ["bind-oci-identity", "--plan-only", *arguments], report + ), + ( + 0, + "", + "", + { + "record_kind": "oci_identity_fetch_plan", + "baseline_manifest_id": "example", + "plan": [{"reference": "example/app"}], + "unfetchable_version_ids": [{"reason": "missing"}], + }, + ), + ) + + def test_main_derives_channels_and_checks_source_binding(self) -> None: + """Publish the derivation summary only when its source binding stays stable.""" + path = str(self.write("manifest.json", "{}")) + output = self.root / "channels" + args = [ + "derive-channels", + path, + "--policies", + str(self.root), + "-o", + str(output), + ] + with ( + patch.object( + kr, "derive_channels_command", return_value={"records_emitted": 1} + ), + patch.object( + kr, "registry_generator_source_binding", return_value={"source": 1} + ) as binding, + ): + self.assertEqual( + self.run_registry(args, output), + (0, '{"records_emitted":1}\n', "", None), + ) + binding.side_effect = [{"source": 1}, {"source": 2}] + self.assertEqual( + self.run_registry(args, output), + ( + 2, + "", + "knowledge-registry: registry generator source changed during channel derivation\n", + None, + ), + ) + + +class ScannerBranchTests(FilesTestCase): + """Exercise scanner defaults and early exits with temporary fixtures.""" + + def test_normalization_empty_and_unusable_arguments(self) -> None: + """Preserve configurations with no eligible argument spans.""" + data = ( + b"mcp_servers.plain = 1\n" + b'mcp_servers.no_args.command = "example"\n' + b'mcp_servers.other.args = ["--projection", 1]\n' + ) + self.assertEqual(kr.normalize_codex_projection_references(data), data) + self.assertEqual(kr.normalize_codex_projection_references(b"["), b"[") + canonical = ( + b'[mcp_servers.app]\nargs = ["--projection", "' + + kr.CODEX_CANONICAL_PROJECTION_REF + + b'"]\n' + ) + self.assertEqual(kr.normalize_codex_projection_references(canonical), canonical) + + def test_chart_lock_without_sibling_or_tracking(self) -> None: + """Record a root-missing lock and its undeclared dependency.""" + text = "dependencies:\n - name: child\n" + path = self.write("Chart.lock", text) + self.track() + check_output( + self, + EXPECTED, + "chart-lock-no-sibling", + kr.scan_chart_lock, + kr.Builder(), + self.root, + path, + text.encode(), + text, + ) + + def test_chart_lock_missing_declared_entry(self) -> None: + """Report tracked locks with no entry for a declared dependency.""" + self.write( + "Chart.yaml", "name: app\nversion: 2.0.0\ndependencies:\n - name: child\n" + ) + self.track("Chart.lock") + path = self.write("Chart.lock", "") + check_output( + self, + EXPECTED, + "chart-lock-missing-entry", + kr.scan_chart_lock, + kr.Builder(), + self.root, + path, + b"", + "", + ) + + def test_pyproject_omitted_metadata_and_optional_requirements(self) -> None: + """Use the project path and keep extras and markers without version constraints.""" + text = '[project]\ndependencies = ["Example_Dep[extra]", "other; python_version < 3.15", "@ invalid"]\n' + path = self.write("app/pyproject.toml", text) + check_output( + self, + EXPECTED, + "pyproject-defaults", + kr.scan_pyproject, + kr.Builder(), + self.root, + path, + text.encode(), + text, + ) + + def test_containerd_hosts_empty_and_single_endpoint(self) -> None: + """Distinguish missing endpoints, a bare mirror, and a single server.""" + path = self.write("hosts.toml", "") + for label, text in ( + ("containerd-no-endpoints", 'other = "example"'), + ("containerd-bare-mirror", '[host]\n"https://mirror.example.org" = true'), + ("containerd-server-only", '\nserver = "https://registry.example.org"'), + ("containerd-empty-hosts", "[host]"), + ): + check_output( + self, + EXPECTED, + label, + kr.scan_containerd_hosts, + kr.Builder(), + self.root, + path, + text.encode(), + text, + ) + + def test_codex_config_empty_servers(self) -> None: + """Distinguish missing servers, empty servers, and an invalid server entry.""" + path = self.write("config.toml", "") + for label, text in ( + ("codex-missing", ""), + ("codex-empty", "[mcp_servers]"), + ("codex-non-table-entry", "[mcp_servers]\napp = true"), + ): + check_output( + self, + EXPECTED, + label, + kr.scan_codex_config, + kr.Builder(), + self.root, + path, + text.encode(), + text, + ) + + def test_script_dependencies_empty_and_unresolved_pin(self) -> None: + """Skip unrelated imports and preserve an unresolved sibling constraint.""" + path = self.write("app.py", "") + self.write("requirements.txt", "PyYAML>=1.2.3\n") + self.track("app.py", "requirements.txt") + for label, text in ( + ("script-empty", "# import yaml\nimport pathlib\n"), + ("script-ranged-pin", "import yaml\n"), + ): + check_output( + self, + EXPECTED, + label, + kr.scan_script_dependencies, + kr.Builder(), + self.root, + path, + text.encode(), + text, + ) + + def test_workflow_install_defaults_and_invalid_json(self) -> None: + """Use the directory fallback and report malformed tracked JSON.""" + builder, source, component, version = local_builder() + self.root /= "app" + self.write("package.json", "{}") + self.write("bad/package.json", "{") + self.track("package.json", "bad/package.json") + check_output( + self, + EXPECTED, + "workflow-defaults", + kr.add_workflow_manifest_install, + builder, + self.root, + source, + component, + version, + working_directory=None, + locator="/steps/0", + ) + check_output( + self, + EXPECTED, + "workflow-bad-json", + kr.add_workflow_manifest_install, + builder, + self.root, + source, + component, + version, + working_directory="bad", + locator="/steps/1", + )