generated from coulomb/repo-seed
Coevolution workplan extension
This commit is contained in:
@@ -604,6 +604,43 @@ def test_analyze_repository_can_use_optional_llm_extractor(tmp_path):
|
||||
assert "1 candidate ability" in decisions[0].notes
|
||||
|
||||
|
||||
def test_analyze_repository_can_disable_optional_llm_extractor(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text(
|
||||
"# Email Router\nRoutes incoming customer email.\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
store = RegistryStore(tmp_path / "registry.sqlite3")
|
||||
store.initialize()
|
||||
extractor = FakeLLMExtractor(
|
||||
[
|
||||
ExtractedAbility(
|
||||
name="Business Email Routing",
|
||||
description="Route incoming messages.",
|
||||
source_paths=["README.md"],
|
||||
)
|
||||
]
|
||||
)
|
||||
service = RegistryService(
|
||||
store,
|
||||
ingestion=GitIngestionService(tmp_path / "checkouts"),
|
||||
llm_extractor=extractor,
|
||||
)
|
||||
repository = service.register_repository(name="Email Router", url=str(source))
|
||||
|
||||
summary = service.analyze_repository(
|
||||
repository.id,
|
||||
use_llm_assistance=False,
|
||||
)
|
||||
graph = service.candidate_graph(repository.id, summary.analysis_run.id)
|
||||
decisions = service.list_review_decisions(repository.id, summary.analysis_run.id)
|
||||
|
||||
assert extractor.calls == []
|
||||
assert graph.abilities[0].name == "Route Incoming Customer Email"
|
||||
assert all(decision.action != "llm_extraction_used" for decision in decisions)
|
||||
|
||||
|
||||
def test_analyze_repository_falls_back_when_optional_llm_extractor_returns_no_candidates(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
@@ -623,6 +660,40 @@ def test_analyze_repository_falls_back_when_optional_llm_extractor_returns_no_ca
|
||||
assert graph.abilities[0].name == "Support Fallback"
|
||||
|
||||
|
||||
def test_analyze_repository_can_trusted_auto_approve_candidates(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text(
|
||||
"# Auto Approved\nReports health over HTTP.\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(source / "app.py").write_text(
|
||||
"from fastapi import FastAPI\n"
|
||||
"app = FastAPI()\n"
|
||||
'@app.get("/health")\n'
|
||||
"def health():\n"
|
||||
" return {}\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
service = make_service(tmp_path)
|
||||
repository = service.register_repository(name="Auto Approved", url=str(source))
|
||||
|
||||
summary = service.analyze_repository(
|
||||
repository.id,
|
||||
trusted_auto_approve=True,
|
||||
use_llm_assistance=False,
|
||||
)
|
||||
ability_map = service.ability_map(repository.id)
|
||||
graph = service.candidate_graph(repository.id, summary.analysis_run.id)
|
||||
decisions = service.list_review_decisions(repository.id, summary.analysis_run.id)
|
||||
|
||||
assert service.get_repository(repository.id).status == "indexed"
|
||||
assert graph.abilities[0].status == "approved"
|
||||
assert ability_map.abilities[0].name == "Report Health Over HTTP"
|
||||
assert decisions[0].action == "trusted_auto_approve_candidate_graph"
|
||||
assert "deterministic candidate generation" in decisions[0].notes
|
||||
|
||||
|
||||
def test_analyze_repository_records_llm_failure_and_falls_back(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
|
||||
@@ -1087,6 +1087,8 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
assert "Registering repository..." in index_response.text
|
||||
assert "Password or access token" in index_response.text
|
||||
assert "Explore after registration" in index_response.text
|
||||
assert "Use LLM assistance if configured" in index_response.text
|
||||
assert "Trusted auto-populate after analysis" in index_response.text
|
||||
|
||||
create_response = client.post(
|
||||
"/ui/repos",
|
||||
@@ -1096,6 +1098,7 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
"access_username": "",
|
||||
"access_password": "",
|
||||
"explore_after_registration": "",
|
||||
"use_llm_assistance": "1",
|
||||
},
|
||||
follow_redirects=False,
|
||||
)
|
||||
@@ -1108,6 +1111,8 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
assert "Run Analysis" in detail_response.text
|
||||
assert "Running analysis..." in detail_response.text
|
||||
assert "Analyze cached checkout without fetching upstream" in detail_response.text
|
||||
assert "Use LLM assistance if configured" in detail_response.text
|
||||
assert "Trusted auto-populate after analysis" in detail_response.text
|
||||
assert "Repository Metadata" in detail_response.text
|
||||
|
||||
edit_repository_response = client.post(
|
||||
@@ -1128,6 +1133,7 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
f"{repository_path}/analysis-runs",
|
||||
data={
|
||||
"source_path": "",
|
||||
"use_llm_assistance": "1",
|
||||
"access_username": "",
|
||||
"access_password": "",
|
||||
},
|
||||
@@ -1266,7 +1272,7 @@ def test_ui_register_analyze_and_approve_loop(tmp_path):
|
||||
)
|
||||
second_run_response = client.post(
|
||||
f"{repository_path}/analysis-runs",
|
||||
data={"source_path": ""},
|
||||
data={"source_path": "", "use_llm_assistance": "1"},
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert second_run_response.status_code == 303
|
||||
@@ -1344,6 +1350,8 @@ def test_ui_register_and_explore_lands_on_analysis_result(tmp_path):
|
||||
"access_username": "",
|
||||
"access_password": "",
|
||||
"explore_after_registration": "1",
|
||||
"use_llm_assistance": "",
|
||||
"trusted_auto_approve": "1",
|
||||
},
|
||||
follow_redirects=False,
|
||||
)
|
||||
@@ -1354,7 +1362,13 @@ def test_ui_register_and_explore_lands_on_analysis_result(tmp_path):
|
||||
result = client.get(response.headers["location"])
|
||||
assert result.status_code == 200
|
||||
assert "Candidate Graph" in result.text
|
||||
assert "approved" in result.text
|
||||
assert "Observed Facts" in result.text
|
||||
assert "trusted_auto_approve_candidate_graph" in result.text
|
||||
|
||||
repository_detail = client.get("/ui/repos/1")
|
||||
assert repository_detail.status_code == 200
|
||||
assert "Use Approved Registry" in repository_detail.text
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user