generated from coulomb/repo-seed
Milestone 0 plus the manual-registry spine from Milestone 1
This commit is contained in:
1
src/repo_registry/core/__init__.py
Normal file
1
src/repo_registry/core/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Core registry domain objects and services."""
|
||||
66
src/repo_registry/core/models.py
Normal file
66
src/repo_registry/core/models.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Repository:
|
||||
id: int
|
||||
name: str
|
||||
url: str
|
||||
description: str | None
|
||||
branch: str
|
||||
status: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Evidence:
|
||||
id: int
|
||||
type: str
|
||||
reference: str
|
||||
strength: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Feature:
|
||||
id: int
|
||||
name: str
|
||||
type: str
|
||||
location: str
|
||||
confidence: float
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Capability:
|
||||
id: int
|
||||
name: str
|
||||
description: str
|
||||
inputs: list[str]
|
||||
outputs: list[str]
|
||||
confidence: float
|
||||
features: list[Feature] = field(default_factory=list)
|
||||
evidence: list[Evidence] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Ability:
|
||||
id: int
|
||||
name: str
|
||||
description: str
|
||||
confidence: float
|
||||
capabilities: list[Capability] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RepositoryAbilityMap:
|
||||
repository: Repository
|
||||
abilities: list[Ability]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SearchResult:
|
||||
repository_id: int
|
||||
repository_name: str
|
||||
match_type: str
|
||||
match_name: str
|
||||
confidence: float
|
||||
116
src/repo_registry/core/service.py
Normal file
116
src/repo_registry/core/service.py
Normal file
@@ -0,0 +1,116 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
from repo_registry.core.models import Repository, RepositoryAbilityMap, SearchResult
|
||||
from repo_registry.storage.sqlite import RegistryStore
|
||||
|
||||
|
||||
class RegistryService:
|
||||
"""Application service for the manual registry MVP."""
|
||||
|
||||
def __init__(self, store: RegistryStore) -> None:
|
||||
self.store = store
|
||||
|
||||
def register_repository(
|
||||
self,
|
||||
*,
|
||||
name: str,
|
||||
url: str,
|
||||
description: str | None = None,
|
||||
branch: str = "main",
|
||||
) -> Repository:
|
||||
return self.store.create_repository(
|
||||
name=name,
|
||||
url=url,
|
||||
description=description,
|
||||
branch=branch,
|
||||
)
|
||||
|
||||
def list_repositories(self) -> list[Repository]:
|
||||
return self.store.list_repositories()
|
||||
|
||||
def get_repository(self, repository_id: int) -> Repository:
|
||||
return self.store.get_repository(repository_id)
|
||||
|
||||
def add_ability(
|
||||
self,
|
||||
repository_id: int,
|
||||
*,
|
||||
name: str,
|
||||
description: str = "",
|
||||
confidence: float = 1.0,
|
||||
) -> int:
|
||||
self.store.get_repository(repository_id)
|
||||
return self.store.create_ability(
|
||||
repository_id,
|
||||
name=name,
|
||||
description=description,
|
||||
confidence=confidence,
|
||||
)
|
||||
|
||||
def add_capability(
|
||||
self,
|
||||
repository_id: int,
|
||||
ability_id: int,
|
||||
*,
|
||||
name: str,
|
||||
description: str = "",
|
||||
inputs: Sequence[str] = (),
|
||||
outputs: Sequence[str] = (),
|
||||
confidence: float = 1.0,
|
||||
) -> int:
|
||||
self.store.ensure_ability(repository_id, ability_id)
|
||||
return self.store.create_capability(
|
||||
repository_id,
|
||||
ability_id,
|
||||
name=name,
|
||||
description=description,
|
||||
inputs=list(inputs),
|
||||
outputs=list(outputs),
|
||||
confidence=confidence,
|
||||
)
|
||||
|
||||
def add_feature(
|
||||
self,
|
||||
repository_id: int,
|
||||
capability_id: int,
|
||||
*,
|
||||
name: str,
|
||||
type: str,
|
||||
location: str = "",
|
||||
confidence: float = 1.0,
|
||||
) -> int:
|
||||
self.store.ensure_capability(repository_id, capability_id)
|
||||
return self.store.create_feature(
|
||||
repository_id,
|
||||
capability_id,
|
||||
name=name,
|
||||
type=type,
|
||||
location=location,
|
||||
confidence=confidence,
|
||||
)
|
||||
|
||||
def add_evidence(
|
||||
self,
|
||||
repository_id: int,
|
||||
capability_id: int,
|
||||
*,
|
||||
type: str,
|
||||
reference: str,
|
||||
strength: str = "medium",
|
||||
) -> int:
|
||||
self.store.ensure_capability(repository_id, capability_id)
|
||||
return self.store.create_evidence(
|
||||
repository_id,
|
||||
capability_id,
|
||||
type=type,
|
||||
reference=reference,
|
||||
strength=strength,
|
||||
)
|
||||
|
||||
def ability_map(self, repository_id: int) -> RepositoryAbilityMap:
|
||||
return self.store.get_ability_map(repository_id)
|
||||
|
||||
def search(self, query: str) -> list[SearchResult]:
|
||||
return self.store.search(query)
|
||||
Reference in New Issue
Block a user