File size: 3,895 Bytes
c4916b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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",
    ]