generated from coulomb/repo-seed
Milestone 3: candidate graph generation
This commit is contained in:
@@ -56,6 +56,67 @@ class ScanSummary:
|
||||
facts: list[ObservedFact]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SourceReference:
|
||||
fact_id: int | None
|
||||
path: str
|
||||
kind: str
|
||||
name: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CandidateEvidence:
|
||||
id: int
|
||||
type: str
|
||||
reference: str
|
||||
strength: str
|
||||
status: str
|
||||
source_refs: list[SourceReference]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CandidateFeature:
|
||||
id: int
|
||||
name: str
|
||||
type: str
|
||||
location: str
|
||||
confidence: float
|
||||
status: str
|
||||
source_refs: list[SourceReference]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CandidateCapability:
|
||||
id: int
|
||||
name: str
|
||||
description: str
|
||||
inputs: list[str]
|
||||
outputs: list[str]
|
||||
confidence: float
|
||||
status: str
|
||||
source_refs: list[SourceReference]
|
||||
features: list[CandidateFeature] = field(default_factory=list)
|
||||
evidence: list[CandidateEvidence] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CandidateAbility:
|
||||
id: int
|
||||
name: str
|
||||
description: str
|
||||
confidence: float
|
||||
status: str
|
||||
source_refs: list[SourceReference]
|
||||
capabilities: list[CandidateCapability] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CandidateGraph:
|
||||
repository: Repository
|
||||
analysis_run: AnalysisRun
|
||||
abilities: list[CandidateAbility]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Evidence:
|
||||
id: int
|
||||
|
||||
@@ -4,12 +4,14 @@ from collections.abc import Sequence
|
||||
|
||||
from repo_registry.core.models import (
|
||||
AnalysisRun,
|
||||
CandidateGraph,
|
||||
ObservedFact,
|
||||
Repository,
|
||||
RepositoryAbilityMap,
|
||||
ScanSummary,
|
||||
SearchResult,
|
||||
)
|
||||
from repo_registry.candidate_graph.generator import CandidateGraphGenerator
|
||||
from repo_registry.repo_ingestion.git import GitIngestionService
|
||||
from repo_registry.repo_scanning.scanner import DeterministicScanner
|
||||
from repo_registry.storage.sqlite import RegistryStore
|
||||
@@ -26,6 +28,7 @@ class RegistryService:
|
||||
self.store = store
|
||||
self.scanner = DeterministicScanner()
|
||||
self.ingestion = ingestion or GitIngestionService()
|
||||
self.candidate_generator = CandidateGraphGenerator()
|
||||
|
||||
def register_repository(
|
||||
self,
|
||||
@@ -79,6 +82,8 @@ class RegistryService:
|
||||
else None
|
||||
)
|
||||
facts = self.store.list_observed_facts(repository_id, completed_run.id)
|
||||
candidates = self.candidate_generator.generate(repository, facts)
|
||||
self.store.replace_candidate_graph(repository_id, completed_run.id, candidates)
|
||||
return ScanSummary(
|
||||
analysis_run=completed_run,
|
||||
snapshot=snapshot,
|
||||
@@ -95,6 +100,9 @@ class RegistryService:
|
||||
) -> list[ObservedFact]:
|
||||
return self.store.list_observed_facts(repository_id, analysis_run_id)
|
||||
|
||||
def candidate_graph(self, repository_id: int, analysis_run_id: int) -> CandidateGraph:
|
||||
return self.store.get_candidate_graph(repository_id, analysis_run_id)
|
||||
|
||||
def add_ability(
|
||||
self,
|
||||
repository_id: int,
|
||||
|
||||
Reference in New Issue
Block a user