ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
kcmcp_client.h
Go to the documentation of this file.
1/**
2 * @file kcmcp_client.h
3 * @brief In-extension KCMCP client: compile a Boolean problem on a warm,
4 * socket-attached knowledge compiler instead of spawning a CLI tool.
5 *
6 * Speaks the protocol defined in @c doc/source/dev/kc-server-protocol.rst,
7 * over the shared @c kcmcp_protocol codec. Used by
8 * @c BooleanCircuit::compilation() when the selected compile tool is a
9 * registry record of @c kind @c "kcmcp". The reference server is
10 * @c tdkc @c --kcmcp (see @c kcmcp_server.h).
11 */
12#ifndef PROVSQL_KCMCP_CLIENT_H
13#define PROVSQL_KCMCP_CLIENT_H
14
15#include <cstdint>
16#include <string>
17
18namespace provsql {
19
20/**
21 * @brief Compile @p problem on a KCMCP server and return its d-DNNF NNF text.
22 *
23 * Connects to @p endpoint (@c "unix:/path" or @c "host:port"), performs the
24 * HELLO handshake, issues one @c compile REQUEST for @p problem in the given
25 * @p input_format (0 = @c dimacs-cnf, 1 = @c circuit-bcs12) wanting
26 * @c ddnnf-nnf output, and returns the RESULT's NNF text verbatim (parsed by
27 * @c BooleanCircuit::parseDDNNF, exactly as the CLI temp-file path is). A
28 * fresh connection per call.
29 *
30 * Honours PostgreSQL query-cancel / @c statement_timeout while waiting: a
31 * pending cancel closes the socket (so the server abandons the job) and is
32 * then raised, mirroring the cancel discipline in @c external_tool.cpp.
33 * Throws @c std::runtime_error on any connect / protocol / server-ERROR
34 * failure so the caller can fall back to the CLI path.
35 */
36std::string kcmcp_compile(const std::string &endpoint,
37 uint8_t input_format,
38 const std::string &problem);
39
40} // namespace provsql
41
42#endif // PROVSQL_KCMCP_CLIENT_H
std::string kcmcp_compile(const std::string &endpoint, uint8_t input_format, const std::string &problem)
Compile problem on a KCMCP server and return its d-DNNF NNF text.