TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
stuck_report.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// The stuck report (design doc 17 §3, issue #26 stage 0): what failed and why, as JSON that an advisor (a person, a script
4// or a model) can act on. It is built from a finished route, is useful on its own (`route --stuck-report FILE`), and is
5// what `route --advisor CMD` sends to the advisor on stdin.
6//
7// The report quotes names from the board (nets, parts), which makes it a prompt-injection surface and, sent to a cloud
8// model, a disclosure. So it says exactly what it contains (`disclosure`), is limited in size, and can be redacted: with
9// `redact` every net and part gets an alias (N1, P3) and the advice that comes back uses the aliases (advice::unalias).
10#include <string>
11
12#include <nlohmann/json.hpp>
13
14#include "advice/advice.hpp"
15#include "model/board.hpp"
16#include "model/rules.hpp"
17#include "route/router.hpp"
18
19namespace tmk::advice {
20
21struct StuckInput {
22 const model::Board* board = nullptr;
23 const model::DesignRules* rules = nullptr;
24 const route::RouteResult* result = nullptr;
25 std::string board_name; // the file name, no path
26 double seconds = 0; // wall time of the run that produced the result
27 nlohmann::json variants; // rows {"variant", "name", "routed", "seconds"} of that run; null = none
28 nlohmann::json previous_advice; // the report of advice already tried (Applied::report) with its outcome; null = none
29 bool redact = false; // aliases for net and part names; no part values or library ids
30 int max_unrouted = 40; // the longest unrouted list sent (the rest are counted)
31 double region_margin_mm = 1.5; // around the two pads of a connection: the region whose crowding is described
32 // Escape analysis of the dense packages (route/escape.hpp, the `escape` command): which pins cannot leave their package at all under
33 // the board's rules, and the analysis's own hint. Cheap (0.2 s on a 163-ball array). Run with the same obstacle options as the route.
34 bool escape_analysis = true;
35 bool soft_zones = false;
37};
38
40 nlohmann::json json;
41 AliasMap aliases; // filled when redacting
42};
43
45
46} // namespace tmk::advice
The advice file (design doc 17, issue #26): typed hints for the router, written by a person,...
The board model (design doc 02 §3): every object TraceMaker reads from a .kicad_pcb,...
StuckReport build_stuck_report(const StuckInput &in)
TraceMaker's detailed router, version 1 (roadmap M4; design doc 05 §2, §5).
Design rules as KiCad defines them (design doc 08 §3–4): board minimums and net classes from the ....
Aliases for net names and part references (a redacted stuck report): the advice an advisor writes use...
Definition advice.hpp:105
nlohmann::json previous_advice
the report of advice already tried (Applied::report) with its outcome; null = none
bool escape_analysis
Escape analysis of the dense packages (route/escape.hpp, the escape command): which pins cannot leave...
const route::RouteResult * result
double seconds
wall time of the run that produced the result
const model::Board * board
nlohmann::json variants
rows {"variant", "name", "routed", "seconds"} of that run; null = none
int max_unrouted
the longest unrouted list sent (the rest are counted)
bool redact
aliases for net and part names; no part values or library ids
double region_margin_mm
around the two pads of a connection: the region whose crowding is described
std::string board_name
the file name, no path
const model::DesignRules * rules
AliasMap aliases
filled when redacting