TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
advisor.hpp File Reference

The advisor protocol (design doc 17 §5): an advisor is any executable that reads a stuck report (JSON) on stdin and writes an advice file (JSON) on stdout. More...

#include <string>
#include <nlohmann/json.hpp>
#include "advice/advice.hpp"

Go to the source code of this file.

Classes

struct  tmk::advice::ProcessResult
struct  tmk::advice::AdvisorOptions
struct  tmk::advice::Consulted

Namespaces

namespace  tmk
namespace  tmk::advice

Functions

ProcessResult tmk::advice::run_process (const std::string &command, const std::string &input, double timeout_s, std::size_t max_out=std::size_t{1}<< 20, std::size_t max_err=std::size_t{1}<< 16)
 Runs command with /bin/sh -c in its own process group, feeds it input on stdin, and collects stdout (at most max_out bytes) and stderr (at most max_err).
Consulted tmk::advice::consult_advisor (const AdvisorOptions &opt, const nlohmann::json &report, const AliasMap &aliases, const std::string &advice_name)
 Sends report to the advisor and reads its advice.

Detailed Description

The advisor protocol (design doc 17 §5): an advisor is any executable that reads a stuck report (JSON) on stdin and writes an advice file (JSON) on stdout.

The engine starts it through the shell, with a time limit, and treats whatever comes back as untrusted: the answer must be exactly one advice file and passes the same strict checks as a file written by hand. A missing, slow, failing or nonsensical advisor is a warning, never an error of the run (rule 5, doc 17 §6).

Definition in file advisor.hpp.