generated from coulomb/repo-seed
service logic for facts, chunks, candidates, and current-approved-vs-target comparison
This commit is contained in:
@@ -509,6 +509,69 @@ def test_approve_candidate_graph_publishes_ability_map_once(tmp_path):
|
||||
assert decisions[0].notes == "Looks good for the first pass."
|
||||
|
||||
|
||||
def test_analysis_run_diff_keeps_approved_map_stable_until_change_approval(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
(source / "README.md").write_text("# Example\n", encoding="utf-8")
|
||||
app_file = source / "app.py"
|
||||
app_file.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="Example", url=str(source))
|
||||
first_summary = service.analyze_repository(repository.id)
|
||||
approved_before = service.approve_candidate_graph(
|
||||
repository.id,
|
||||
first_summary.analysis_run.id,
|
||||
)
|
||||
|
||||
app_file.write_text(
|
||||
"from fastapi import FastAPI\n"
|
||||
"app = FastAPI()\n"
|
||||
'@app.get("/ready")\n'
|
||||
"def ready():\n"
|
||||
" return {}\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
second_summary = service.analyze_repository(repository.id)
|
||||
approved_after_analysis = service.ability_map(repository.id)
|
||||
diff = service.diff_analysis_runs(
|
||||
repository.id,
|
||||
first_summary.analysis_run.id,
|
||||
second_summary.analysis_run.id,
|
||||
)
|
||||
|
||||
assert approved_after_analysis.abilities[0].capabilities[0].features[0].name == (
|
||||
approved_before.abilities[0].capabilities[0].features[0].name
|
||||
)
|
||||
assert any(item.item_type == "feature" for item in diff.candidates.added)
|
||||
assert any(item.item_type == "feature" for item in diff.candidates.removed)
|
||||
assert any(item.item_type == "feature" for item in diff.approved_entries.added)
|
||||
assert any(item.item_type == "feature" for item in diff.approved_entries.removed)
|
||||
|
||||
approved_after_review = service.approve_analysis_run_changes(
|
||||
repository.id,
|
||||
second_summary.analysis_run.id,
|
||||
notes="Accept route change.",
|
||||
)
|
||||
|
||||
assert approved_after_review.abilities[0].capabilities[0].features[0].name == (
|
||||
"GET /ready"
|
||||
)
|
||||
decisions = service.list_review_decisions(
|
||||
repository.id,
|
||||
second_summary.analysis_run.id,
|
||||
)
|
||||
assert decisions[0].action == "approve_analysis_run_changes"
|
||||
assert decisions[0].notes == "Accept route change."
|
||||
|
||||
|
||||
def test_reject_candidate_ability_excludes_it_from_approval(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
|
||||
@@ -45,6 +45,13 @@ def test_openapi_groups_agent_facing_endpoints():
|
||||
assert components["CandidateGraphResponse"]["examples"][0]["abilities"][0][
|
||||
"status"
|
||||
] == "pending"
|
||||
assert (
|
||||
"/repos/{repository_id}/analysis-runs/{base_analysis_run_id}/diff/"
|
||||
"{target_analysis_run_id}"
|
||||
) in schema["paths"]
|
||||
assert (
|
||||
"/repos/{repository_id}/analysis-runs/{analysis_run_id}/changes/approve"
|
||||
) in schema["paths"]
|
||||
|
||||
|
||||
def test_docs_endpoint_is_available():
|
||||
|
||||
Reference in New Issue
Block a user