Add structured compiler diagnostics
This commit is contained in:
parent
0fe968c475
commit
24bd13f9d9
20 changed files with 1386 additions and 58 deletions
|
|
@ -35,6 +35,7 @@ from .models import (
|
|||
ProposalWriter,
|
||||
)
|
||||
from .render_config import load_render_config
|
||||
from .telemetry import increment, stage
|
||||
|
||||
SOURCE_GENERATION_SCHEMA_VERSION = 1
|
||||
GENERIC_SOURCE_CONTRACT = "docforge-core:0.7.1:index:1"
|
||||
|
|
@ -709,6 +710,7 @@ class Project:
|
|||
return cls(_load_descriptor(root))
|
||||
|
||||
def load(self) -> ProjectSnapshot:
|
||||
increment("project_loads")
|
||||
descriptor_bytes = self.descriptor.descriptor_path.read_bytes()
|
||||
if hashlib.sha256(descriptor_bytes).hexdigest() != self.descriptor.descriptor_hash:
|
||||
raise DocForgeError(
|
||||
|
|
@ -730,7 +732,15 @@ class Project:
|
|||
nodes: list[Node] = []
|
||||
edges: list[Edge] = []
|
||||
for path in ordered_sources:
|
||||
source_nodes, source_edges = _load_source_file(self.descriptor, path, captured[path])
|
||||
raw = captured[path]
|
||||
increment("source_files_parsed")
|
||||
increment("source_bytes_parsed", len(raw))
|
||||
with stage("source.parse"):
|
||||
source_nodes, source_edges = _load_source_file(
|
||||
self.descriptor,
|
||||
path,
|
||||
raw,
|
||||
)
|
||||
nodes.extend(source_nodes)
|
||||
edges.extend(source_edges)
|
||||
if len(nodes) > self.descriptor.limits.max_nodes:
|
||||
|
|
@ -804,6 +814,11 @@ class Project:
|
|||
def incremental_state(self) -> ProjectState | None:
|
||||
"""Return current source identity without reading or parsing canonical source bytes."""
|
||||
|
||||
increment("source_generation_checks")
|
||||
with stage("source.generation"):
|
||||
return self._incremental_state()
|
||||
|
||||
def _incremental_state(self) -> ProjectState | None:
|
||||
path = self.generation_path
|
||||
if not path.is_file() or path.is_symlink():
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue