Milestone 0 plus the manual-registry spine from Milestone 1

This commit is contained in:
2026-04-25 22:00:26 +02:00
parent a833d4f82c
commit 3b2d1667bb
13 changed files with 1000 additions and 2 deletions

View File

@@ -0,0 +1 @@
"""Core registry domain objects and services."""

View 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

View 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)