Repository navigation
fix(capabilities): remove consolidated uFlow/uKnowledge repo requirements #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fredporter
merged 3 commits into
main
from
fix/capability-requirements-uflow-uknowledge
Sep 16, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
ab27662
fix(capabilities): remove consolidated uFlow/uKnowledge repos from re…
fredporter 8d0ab30
test(capabilities): isolate developer.guided preflight test prerequis…
fredporter ab1281a
fix(capabilities): auto-filter consolidated repos from user overrides…
fredporter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| """Integration tests for Capabilities Preflight and Readiness API endpoints.""" | ||
| from __future__ import annotations | ||
|
|
||
| import tempfile | ||
| from pathlib import Path | ||
| from unittest.mock import patch | ||
|
|
||
| from aiohttp import web | ||
| from aiohttp.test_utils import AioHTTPTestCase | ||
|
|
||
| from app.api.extensions_api import ( | ||
| handle_capabilities_readiness, | ||
| handle_capability_preflight, | ||
| ) | ||
| from app.core.settings import settings | ||
| from app.extensions.registry import registry | ||
|
|
||
|
|
||
| class CapabilitiesPreflightAPITest(AioHTTPTestCase): | ||
| async def get_application(self): | ||
| app = web.Application() | ||
| registry.discover() | ||
| registry.register_routes(app) | ||
| app.router.add_get( | ||
| "/api/capabilities/{capability}/preflight", | ||
| handle_capability_preflight, | ||
| ) | ||
| app.router.add_get( | ||
| "/api/capabilities/readiness", | ||
| handle_capabilities_readiness, | ||
| ) | ||
| return app | ||
|
|
||
| async def test_capability_requirements_consolidated_repos_contract(self): | ||
| from app.api.extensions_api import _load_capability_requirements, CONSOLIDATED_REPOS | ||
| reqs, _ = _load_capability_requirements() | ||
| assert reqs["workflow.run"]["repos"] == [] | ||
| assert reqs["knowledge.search"]["repos"] == [] | ||
| assert reqs["developer.guided"]["repos"] == ["uCore", "uCode"] | ||
| for cap, spec in reqs.items(): | ||
| repos = spec.get("repos", []) | ||
| assert not (CONSOLIDATED_REPOS & set(repos)), f"{cap} must not require consolidated repos: {repos}" | ||
|
|
||
| async def test_workflow_run_preflight_ready(self): | ||
| resp = await self.client.get("/api/capabilities/workflow.run/preflight") | ||
| assert resp.status == 200 | ||
| data = await resp.json() | ||
| assert data["capability"] == "workflow.run" | ||
| assert data["ready"] is True | ||
| assert data["repair_required"] is False | ||
| assert data["repair"] == [] | ||
|
|
||
| async def test_knowledge_search_preflight_ready(self): | ||
| resp = await self.client.get("/api/capabilities/knowledge.search/preflight") | ||
| assert resp.status == 200 | ||
| data = await resp.json() | ||
| assert data["capability"] == "knowledge.search" | ||
| assert data["ready"] is True | ||
| assert data["repair_required"] is False | ||
| assert data["repair"] == [] | ||
|
|
||
| async def test_developer_guided_preflight_excludes_uflow_and_uknowledge(self): | ||
| resp = await self.client.get("/api/capabilities/developer.guided/preflight") | ||
| data = await resp.json() | ||
| assert data["capability"] == "developer.guided" | ||
| repair_ids = [item.get("id") for item in data.get("repair", [])] | ||
| assert "uFlow" not in repair_ids | ||
| assert "uKnowledge" not in repair_ids | ||
|
|
||
| async def test_developer_guided_preflight_ready_when_prereqs_met(self): | ||
| async def fake_check_tool(tool_id: str): | ||
| return {"installed": True, "ok": True} | ||
|
|
||
| with tempfile.TemporaryDirectory() as td: | ||
| root = Path(td) | ||
| (root / "uCore").mkdir() | ||
| (root / "uCode").mkdir() | ||
| with patch.object(settings, "udos_root", root), \ | ||
| patch("app.api.extensions_api.check_tool", side_effect=fake_check_tool): | ||
| resp = await self.client.get("/api/capabilities/developer.guided/preflight") | ||
| assert resp.status == 200 | ||
| data = await resp.json() | ||
| assert data["capability"] == "developer.guided" | ||
| assert data["ready"] is True | ||
| assert data["repair_required"] is False | ||
| assert data["repair"] == [] | ||
|
|
||
| async def test_capabilities_readiness_batch_ready(self): | ||
| resp = await self.client.get( | ||
| "/api/capabilities/readiness?capabilities=workflow.run,knowledge.search" | ||
| ) | ||
| assert resp.status == 200 | ||
| data = await resp.json() | ||
| assert data["ready"] is True | ||
| assert data["count"] == 2 | ||
| caps = {c["capability"]: c for c in data["capabilities"]} | ||
| assert "workflow.run" in caps | ||
| assert caps["workflow.run"]["ready"] is True | ||
| assert "knowledge.search" in caps | ||
| assert caps["knowledge.search"]["ready"] is True | ||
|
|
||
| async def test_unknown_capability_preflight_missing(self): | ||
| resp = await self.client.get("/api/capabilities/nonexistent.capability/preflight") | ||
| assert resp.status == 412 | ||
| data = await resp.json() | ||
| assert data["ready"] is False | ||
| assert data["repair_required"] is True | ||
| assert any( | ||
| item.get("kind") == "config" and item.get("id") == "capability_requirements" | ||
| for item in data["repair"] | ||
| ) | ||
|
|
||
| async def test_legacy_user_override_filters_consolidated_repos(self): | ||
| import json | ||
|
|
||
| with tempfile.TemporaryDirectory() as td: | ||
| cfg_dir = Path(td) | ||
| override_file = cfg_dir / "capability_requirements.json" | ||
| # Simulate legacy override file containing obsolete uFlow / uKnowledge repo requirements | ||
| override_file.write_text( | ||
| json.dumps( | ||
| { | ||
| "workflow.run": { | ||
| "extensions": ["uflow"], | ||
| "tools": ["git"], | ||
| "repos": ["uFlow"], | ||
| "variables": [], | ||
| "secrets": [], | ||
| } | ||
| } | ||
| ), | ||
| encoding="utf-8", | ||
| ) | ||
| with patch.object(settings, "config_dir", cfg_dir): | ||
| resp = await self.client.get("/api/capabilities/workflow.run/preflight") | ||
| assert resp.status == 200 | ||
| data = await resp.json() | ||
| assert data["ready"] is True | ||
| assert data["repair_required"] is False | ||
| assert data["repair"] == [] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.