generated from coulomb/repo-seed
Milestone 6 API completeness
This commit is contained in:
@@ -34,12 +34,37 @@ class RepositoryCreate(BaseModel):
|
||||
description: str | None = None
|
||||
branch: str = "main"
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{
|
||||
"url": "https://github.com/example/repository.git",
|
||||
"name": "Example Repository",
|
||||
"description": "Optional human-readable repository summary.",
|
||||
"branch": "main",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class AbilityCreate(BaseModel):
|
||||
name: str
|
||||
description: str = ""
|
||||
confidence: float = Field(default=1.0, ge=0.0, le=1.0)
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{
|
||||
"name": "Business Email Routing",
|
||||
"description": "Route inbound messages to the right team.",
|
||||
"confidence": 0.92,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CapabilityCreate(BaseModel):
|
||||
ability_id: int
|
||||
@@ -49,6 +74,21 @@ class CapabilityCreate(BaseModel):
|
||||
outputs: list[str] = Field(default_factory=list)
|
||||
confidence: float = Field(default=1.0, ge=0.0, le=1.0)
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{
|
||||
"ability_id": 1,
|
||||
"name": "Classify Incoming Email",
|
||||
"description": "Classify messages by intent.",
|
||||
"inputs": ["subject", "body"],
|
||||
"outputs": ["intent", "confidence"],
|
||||
"confidence": 0.88,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class FeatureCreate(BaseModel):
|
||||
capability_id: int
|
||||
@@ -57,6 +97,20 @@ class FeatureCreate(BaseModel):
|
||||
location: str = ""
|
||||
confidence: float = Field(default=1.0, ge=0.0, le=1.0)
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{
|
||||
"capability_id": 1,
|
||||
"name": "POST /api/classify-email",
|
||||
"type": "REST endpoint",
|
||||
"location": "src/routes/classify_email.py",
|
||||
"confidence": 0.84,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class EvidenceCreate(BaseModel):
|
||||
capability_id: int
|
||||
@@ -64,18 +118,52 @@ class EvidenceCreate(BaseModel):
|
||||
reference: str
|
||||
strength: str = "medium"
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{
|
||||
"capability_id": 1,
|
||||
"type": "unit_test",
|
||||
"reference": "tests/test_email_classification.py",
|
||||
"strength": "strong",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class AnalysisRunCreate(BaseModel):
|
||||
source_path: str | None = None
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{},
|
||||
{"source_path": "/path/to/local/repository"},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CandidateGraphApproval(BaseModel):
|
||||
notes: str = ""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [{"notes": "Approved after curator review."}]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CandidateRejection(BaseModel):
|
||||
notes: str = ""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [{"notes": "Rejected because the claim is too generic."}]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CandidateEdit(BaseModel):
|
||||
name: str
|
||||
@@ -83,36 +171,96 @@ class CandidateEdit(BaseModel):
|
||||
confidence: float = Field(default=0.5, ge=0.0, le=1.0)
|
||||
notes: str = ""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{
|
||||
"name": "Service Health Monitoring",
|
||||
"description": "Expose health state for operational checks.",
|
||||
"confidence": 0.9,
|
||||
"notes": "Renamed from generated review seed.",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CandidateCapabilityRelink(BaseModel):
|
||||
target_ability_id: int
|
||||
notes: str = ""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{"target_ability_id": 2, "notes": "Move under operational ability."}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CandidateLeafRelink(BaseModel):
|
||||
target_capability_id: int
|
||||
notes: str = ""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{
|
||||
"target_capability_id": 3,
|
||||
"notes": "Evidence supports a different capability.",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CandidateAbilityMerge(BaseModel):
|
||||
target_ability_id: int
|
||||
notes: str = ""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{"target_ability_id": 2, "notes": "Duplicate ability wording."}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CandidateCapabilityMerge(BaseModel):
|
||||
target_capability_id: int
|
||||
notes: str = ""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [
|
||||
{"target_capability_id": 3, "notes": "Duplicate capability."}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CandidateFeatureMerge(BaseModel):
|
||||
target_feature_id: int
|
||||
notes: str = ""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [{"target_feature_id": 4, "notes": "Duplicate route."}]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CandidateEvidenceMerge(BaseModel):
|
||||
target_evidence_id: int
|
||||
notes: str = ""
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"examples": [{"target_evidence_id": 5, "notes": "Duplicate evidence."}]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
app = FastAPI(title="Repository Ability Registry", version="0.1.0")
|
||||
|
||||
@@ -184,6 +332,18 @@ def list_analysis_runs(
|
||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@app.get("/repos/{repository_id}/analysis-runs/{analysis_run_id}")
|
||||
def get_analysis_run(
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> dict[str, object]:
|
||||
try:
|
||||
return asdict(service.get_analysis_run(repository_id, analysis_run_id))
|
||||
except NotFoundError as exc:
|
||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@app.get("/repos/{repository_id}/observed-facts")
|
||||
def list_observed_facts(
|
||||
repository_id: int,
|
||||
@@ -611,3 +771,17 @@ def search(
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> list[dict[str, object]]:
|
||||
return [asdict(result) for result in service.search(q)]
|
||||
|
||||
|
||||
@app.get("/abilities")
|
||||
def list_abilities(
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> list[dict[str, object]]:
|
||||
return [asdict(ability) for ability in service.list_abilities()]
|
||||
|
||||
|
||||
@app.get("/capabilities")
|
||||
def list_capabilities(
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> list[dict[str, object]]:
|
||||
return [asdict(capability) for capability in service.list_capabilities()]
|
||||
|
||||
Reference in New Issue
Block a user