from typing import Dict, Any, List def generate_patch_plan() -> Dict[str, Any]: return { "stages": [ { "stage": 1, "name": "Core gbridge primitive", "description": "Implement route_capability_call() as the single routing primitive", "files": ["app/gbridge/router.py"], "tests": ["test_capability_endpoints.py"], }, { "stage": 2, "name": "Capability leases", "description": "Implement lease creation, expiration, and endpoint binding", "files": ["app/gbridge/leases.py", "app/gbridge/capabilities.py"], "tests": ["test_gbridge_leases.py"], }, { "stage": 3, "name": "Phone worker bridge", "description": "Implement session creation, worker registration, and job routing", "files": ["app/phone/sessions.py", "app/phone/workers.py", "app/phone/jobs.py", "app/phone/relay.py"], "tests": ["test_phone_sessions.py"], }, { "stage": 4, "name": "Receipt system", "description": "Implement receipt creation, chain hashing, and verification", "files": ["app/gbridge/receipts.py"], "tests": ["test_receipts.py"], }, { "stage": 5, "name": "Five pages", "description": "Build landing, phone, gbridge, windsurf, and receipts pages", "files": ["app/pages/landing.py", "app/pages/phone.py", "app/pages/gbridge.py", "app/pages/windsurf.py", "app/pages/receipts.py"], "tests": [], }, { "stage": 6, "name": "Windsurf integration", "description": "Implement packet generation, MCP manifest, and ingest endpoint", "files": ["app/windsurf/packet.py", "app/windsurf/mcp_export.py", "app/windsurf/ingest.py"], "tests": ["test_windsurf_packet.py", "test_mcp_manifest.py"], }, { "stage": 7, "name": "API wiring", "description": "Wire all API routes into main.py", "files": ["app/api/routes_*.py", "app/main.py"], "tests": [], }, ], "regression_checks": [ "All existing tests still pass", "No secrets in source", "No mocked inference without capability_unavailable fallback", "Receipt chain is unbroken", ], } def prioritize_patch_steps(steps: List[Dict[str, Any]]) -> List[Dict[str, Any]]: return sorted(steps, key=lambda s: s.get("priority", 99)) def generate_acceptance_criteria() -> List[str]: return [ "Landing page renders at /", "Phone bridge renders at /phone", "gbridge explorer renders at /gbridge", "Windsurf page renders at /windsurf", "Receipts page renders at /receipts", "/api/manifest returns product metadata", "/api/gbridge/session creates session", "/worker opens with session token", "Worker WebSocket connects", "Worker advertises at least one capability", "/cap/{capability_name} creates routed job", "Job returns result", "Receipt is created", "Receipt verifies", "/api/windsurf/packet returns valid build packet", "/api/windsurf/mcp returns MCP-style tool manifest", ] def generate_regression_checks() -> List[str]: return [ "No hardcoded secrets", "No mocked inference without fallback", "Receipt chain unbroken", "All pages render without 500", "WebSocket connections close cleanly", ]