Add structured compiler diagnostics
This commit is contained in:
parent
0fe968c475
commit
24bd13f9d9
20 changed files with 1386 additions and 58 deletions
|
|
@ -38,6 +38,7 @@ from .models import (
|
|||
ProposalWriter,
|
||||
RenderConfig,
|
||||
)
|
||||
from .telemetry import increment, stage
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
|
@ -185,6 +186,21 @@ MAX_IMPLEMENTATION_FILES = 4_096
|
|||
MAX_IMPLEMENTATION_BYTES = 64_000_000
|
||||
|
||||
|
||||
def _load_adapter_projection(loader: AdapterLoader) -> AdapterProjection:
|
||||
increment("adapter_projection_loads")
|
||||
with stage("adapter.projection"):
|
||||
return loader.load_projection()
|
||||
|
||||
|
||||
def _extract_adapter_source(
|
||||
loader: IncrementalAdapterLoader,
|
||||
source: AdapterSource,
|
||||
) -> AdapterSourceProjection:
|
||||
increment("adapter_source_extractions")
|
||||
with stage("adapter.extract"):
|
||||
return loader.extract_source(source)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AdapterImplementation:
|
||||
"""One confined implementation boundary that must remain stable for a process."""
|
||||
|
|
@ -256,7 +272,7 @@ class AdapterProject:
|
|||
allowed_relations = manifest.allowed_relations
|
||||
estimated_nodes = manifest.estimated_nodes
|
||||
else:
|
||||
initial = loader.load_projection()
|
||||
initial = _load_adapter_projection(loader)
|
||||
validate_projection(initial)
|
||||
root = initial.root
|
||||
project_id = initial.project_id
|
||||
|
|
@ -370,13 +386,14 @@ class AdapterProject:
|
|||
self._implementation_snapshot = self._capture_implementation(initial=True)
|
||||
|
||||
def load(self) -> ProjectSnapshot:
|
||||
increment("project_loads")
|
||||
self.validate_runtime()
|
||||
canonical_sources = self.canonical_source_paths()
|
||||
captured = {path: path.read_bytes() for path in canonical_sources}
|
||||
projection = (
|
||||
self._load_incremental()
|
||||
if self._incremental_loader is not None
|
||||
else self.loader.load_projection()
|
||||
else _load_adapter_projection(self.loader)
|
||||
)
|
||||
validate_projection(projection)
|
||||
identity = (
|
||||
|
|
@ -411,6 +428,11 @@ class AdapterProject:
|
|||
def incremental_state(self) -> ProjectState | None:
|
||||
"""Return current source identity without reconstructing the complete projection."""
|
||||
|
||||
increment("source_generation_checks")
|
||||
with stage("source.generation"):
|
||||
return self._incremental_state()
|
||||
|
||||
def _incremental_state(self) -> ProjectState | None:
|
||||
self.validate_runtime()
|
||||
loader = self._incremental_loader
|
||||
if loader is None:
|
||||
|
|
@ -509,7 +531,7 @@ class AdapterProject:
|
|||
"incremental_disabled", "Adapter does not implement incremental extraction"
|
||||
)
|
||||
incremental = self._load_incremental()
|
||||
full = self.loader.load_projection()
|
||||
full = _load_adapter_projection(self.loader)
|
||||
validate_projection(full)
|
||||
fields = {
|
||||
"project_id": incremental.project_id == full.project_id,
|
||||
|
|
@ -578,7 +600,7 @@ class AdapterProject:
|
|||
hits: list[str] = []
|
||||
for source in manifest.sources:
|
||||
if source.source_id in invalidated:
|
||||
contribution = loader.extract_source(source)
|
||||
contribution = _extract_adapter_source(loader, source)
|
||||
reparsed.append(source.source_id)
|
||||
cache_record = CachedSource(
|
||||
source_id=source.source_id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue