Skip to content

reporting

generate_execution_strategy_report(router, op)

Generates the Test Execution Strategy report by pre-injecting the plan data.

Source code in wintermute/ai/reporting.py
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
def generate_execution_strategy_report(router: Router, op: object) -> str:
    """
    Generates the Test Execution Strategy report by pre-injecting the plan data.
    """
    # 1. PRE-FETCH DATA (Context Injection)
    # We get the data directly using Python, no AI tool guessing required.
    context_data = get_detailed_test_context(op)

    # Convert to JSON string for the prompt
    context_json = json.dumps(context_data, indent=2)

    # 2. CONSTRUCT PROMPT WITH DATA
    system_instruction = (
        "You are a seasoned Hardware Security Engineer Lead creating a Test Plan Summary. "
        "The testing phase has NOT finished (or hasn't started). "
        "Use the provided JSON context to write the report. "
        "Do NOT hallucinate test cases. Use ONLY the 'detailed_runs' provided.\n"
        "Focus on:\n"
        "1. Scope: Which interfaces (UART, JTAG, etc.) are targeted?\n"
        "2. Strategy: What methodology is used? (Analyze the 'steps' in the JSON)\n"
        "3. Coverage: How many tests per interface?"
    )

    user_prompt = (
        f"Summarize the planned test execution strategy based on the following Test Run Data:\n\n"
        f"```json\n{context_json}\n```"
    )

    # 3. CALL AI
    # We use simple_chat because we already have the tool output
    full_prompt = f"{system_instruction}\n\n{user_prompt}"

    return simple_chat(router, full_prompt)

get_detailed_test_context(op)

Extracts comprehensive planning data including descriptions and steps.

Source code in wintermute/ai/reporting.py
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
def get_detailed_test_context(op: object) -> Dict[str, Any]:
    """
    Extracts comprehensive planning data including descriptions and steps.
    """
    runs_data = []

    # We aggregate by interface to help the AI structure the report
    interfaces_targeted = set()

    for run, tc, _path in collect_test_runs([op]):
        # Extract target info (e.g., "UART:debug-console")
        targets = [f"{b.kind}:{b.object_id}" for b in run.bound]

        # Track unique interfaces for the summary high-level view
        for t in targets:
            if ":" in t:
                interfaces_targeted.add(t.split(":")[0])  # e.g. "UART", "JTAG"

        # Serialize steps if available
        steps_summary = []
        if tc and tc.steps:
            for step in tc.steps:
                # Format: "Tool (Action): Description"
                s_str = f"{step.tool or 'Manual'} ({step.action or 'Check'}): {step.description or step.title}"
                steps_summary.append(s_str)

        runs_data.append(
            {
                "id": run.run_id,
                "test_case": tc.code if tc else "Unknown",
                "name": tc.name if tc else "Unknown",
                "description": tc.description if tc else "",
                "status": run.status.name,
                "targets": targets,
                "execution_mode": tc.execution_mode.name if tc else "unknown",
                "steps": steps_summary,  # <--- The AI needs this to understand the strategy
            }
        )

    return {
        "timestamp": "Current",
        "scope_summary": {
            "total_runs_generated": len(runs_data),
            "interfaces_in_scope": list(interfaces_targeted),
            "pending_execution": len(
                [r for r in runs_data if r["status"] == "not_run"]
            ),
        },
        "detailed_runs": runs_data,
    }

get_findings_context(op)

Extracts ONLY vulnerability data.

Source code in wintermute/ai/reporting.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
def get_findings_context(op: object) -> Dict[str, Any]:
    """Extracts ONLY vulnerability data."""
    vulns = []
    for v, _path in collect_vulnerabilities([op]):
        vulns.append(
            {
                "title": v.title,
                "severity": getattr(v.risk, "severity", "Unknown"),
                "status": "Verified" if v.verified else "Potential",
                "description": v.description,
            }
        )
    return {"phase": "Reporting", "findings": vulns}