Establish Milestone 0 compatibility and quality gates
This commit is contained in:
parent
15a913003c
commit
8ebb78a71d
15 changed files with 1114 additions and 27 deletions
|
|
@ -47,6 +47,7 @@ from docforge.models import (
|
|||
RenderConfig,
|
||||
RenderView,
|
||||
)
|
||||
from docforge.viewer_manager import ViewerManagerClient
|
||||
from docforge.visualization import VisualizationIndexSnapshot
|
||||
|
||||
|
||||
|
|
@ -236,6 +237,13 @@ class OverlappingIncrementalLoader(IncrementalLoader):
|
|||
return self.assemble_projection(manifest, contributions).projection
|
||||
|
||||
|
||||
class NonLogicIncrementalLoader(IncrementalLoader):
|
||||
"""Exercise non-AST incremental caching without publishing function Logic."""
|
||||
|
||||
def extract_source(self, source: AdapterSource) -> AdapterSourceProjection:
|
||||
return replace(super().extract_source(source), logic=())
|
||||
|
||||
|
||||
class AdapterContractTests(unittest.TestCase):
|
||||
def projection(self, root: Path) -> AdapterProjection:
|
||||
foundation = Node(
|
||||
|
|
@ -561,6 +569,60 @@ class AdapterContractTests(unittest.TestCase):
|
|||
self.assertEqual("adapter_policy_forbids_logic", captured.exception.code)
|
||||
self.assertFalse(project.descriptor.index_path.exists())
|
||||
|
||||
def test_no_ast_index_accepts_legacy_and_non_logic_incremental_adapters(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory).resolve()
|
||||
legacy = AdapterProject(
|
||||
Loader(self.projection(root)),
|
||||
cache_root=root / ".cache" / "legacy-no-ast",
|
||||
)
|
||||
legacy_index = ProjectIndex(legacy, allow_logic=False)
|
||||
self.assertEqual(2, legacy_index.build()["node_count"])
|
||||
self.assertEqual(
|
||||
"guide.workflow",
|
||||
legacy_index.get_node("guide.workflow")["node"]["node_id"],
|
||||
)
|
||||
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory).resolve()
|
||||
loader = NonLogicIncrementalLoader(root)
|
||||
project = AdapterProject(
|
||||
loader,
|
||||
cache_root=root / ".cache" / "incremental-no-ast",
|
||||
)
|
||||
index = ProjectIndex(project, allow_logic=False)
|
||||
first = index.build()
|
||||
self.assertEqual(2, first["build"]["reparsed_sources"])
|
||||
loader.extract_calls.clear()
|
||||
|
||||
second = index.build()
|
||||
|
||||
self.assertEqual([], loader.extract_calls)
|
||||
self.assertEqual(2, second["build"]["cache_hits"])
|
||||
self.assertEqual(0, second["build"]["reparsed_sources"])
|
||||
self.assertEqual(0, second["logic_projection_count"])
|
||||
|
||||
def test_no_ast_rejects_preexisting_logic_index_and_viewer_snapshot(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory).resolve()
|
||||
project = AdapterProject(
|
||||
IncrementalLoader(root),
|
||||
cache_root=root / ".cache" / "preexisting-logic",
|
||||
)
|
||||
ProjectIndex(project).build()
|
||||
preserved = ProjectIndex(project, allow_logic=False)
|
||||
|
||||
with self.assertRaises(DocForgeError) as checked:
|
||||
preserved.check(verify_rows=False)
|
||||
self.assertEqual("adapter_policy_forbids_logic", checked.exception.code)
|
||||
|
||||
with self.assertRaises(DocForgeError) as viewed:
|
||||
ViewerManagerClient(
|
||||
preserved,
|
||||
state_path=root / ".cache" / "viewer-state.json",
|
||||
).start()
|
||||
self.assertEqual("adapter_policy_forbids_logic", viewed.exception.code)
|
||||
|
||||
def test_fast_incremental_reads_reverify_a_changed_index_file(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory).resolve()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue