53#include <boost/json.hpp>
107 static std::shared_ptr<OutputDirectory>
Shared(std::filesystem::path
const& root);
110 std::filesystem::path
const&
Root()
const {
return root_; }
133 std::string
PutDefinition(std::string
const& content, std::string
const& kind,
134 std::optional<std::string> external_id = std::nullopt,
135 std::string
const& label = {});
153 void Append(boost::json::object
const& record);
168 void Annotate(std::string
const& run_id, std::int64_t index,
169 std::string
const& key, boost::json::value
const& value);
177 std::vector<boost::json::object>
Scan()
const;
207 void AppendResult(std::string
const& run_id, boost::json::object
const& record);
218 std::vector<boost::json::object>
ResultsOf(std::string
const& run_id)
const;
231 std::filesystem::path DefinitionPath(std::string
const& kind, std::string
const&
id,
232 std::string
const& label)
const;
233 std::optional<std::filesystem::path> FindDefinition(std::string
const&
id)
const;
234 std::filesystem::path ResultsPath(std::string
const& run_id)
const;
235 void EnsureSessionFile();
242 std::filesystem::path root_;
244 std::ofstream session_;
245 std::filesystem::path session_path_;
246 std::mutex append_mutex_;
247 std::map<std::string, std::ofstream> results_streams_;
252 static constexpr std::size_t kMaxOpenResultsFiles = 16;
273 std::string
const& digest_hex,
274 boost::json::object
const& parts);
std::vector< boost::json::object > Scan() const
Every record from every history file, in filename-then-line order.
OutputDirectory(std::filesystem::path root)
Open (creating if needed) the output directory at root, writing the self-documenting README....
void AppendResult(std::string const &run_id, boost::json::object const &record)
Append one payload record to the run's results file (flushed per record, so a kill loses at most the ...
std::string Describe() const
One human line: how much is here (record/file/definition counts + path).
void RefreshIndex() const
(Re)write INDEX.txt: one line per run — when, paths done, op, target description, run id.
std::string GetDefinition(std::string const &id) const
Read a definition's bytes by id (searched across all kinds). Throws if absent.
std::filesystem::path const & Root() const
The directory's root path.
Definition output_directory.hpp:110
void EnsureResultsFile(std::string const &run_id, boost::json::object const &header)
Ensure the run's results file exists, with its self-description header as line 1: {"kind":"results_he...
std::string PutDefinition(std::string const &content, std::string const &kind, std::optional< std::string > external_id=std::nullopt, std::string const &label={})
Store a definition content-addressed; returns its id.
void Annotate(std::string const &run_id, std::int64_t index, std::string const &key, boost::json::value const &value)
Attach metadata to a recorded point: appends an annotation record {"kind":"annotation",...
void Append(boost::json::object const &record)
Append one record to this session's history file.
bool HasDefinition(std::string const &id) const
Whether a definition with this id is present (searched across all kinds).
static std::shared_ptr< OutputDirectory > Shared(std::filesystem::path const &root)
The process-shared OutputDirectory at root: one instance – hence one session history file – per direc...
std::vector< boost::json::object > ResultsOf(std::string const &run_id) const
Every record in the run's results file, header line included, in order.
Definition config_encoding.hpp:66
std::string TimeStampNow()
The record timestamp, now: YYYY-MM-DD HH:MM local time – the one clock format every record kind uses ...
std::string SystemEncodingAsJson(std::string const &encoding_text, std::string const &digest_hex, boost::json::object const &parts)
The archived form of a system definition: a machine-parseable JSON document {"schema",...
std::optional< std::string > AmbientRecordsPath()
Resolve the ambient records directory from the environment – the ONE place the BERTINI_RECORDS_DIR se...
constexpr char RecordSchemaVersion[]
The record-format version tag written on run headers; see docs/records/b2rec-1.md.
Definition output_directory.hpp:62
Definition algorithm_builder.hpp:36
Self-contained SHA-256 (FIPS 180-4) and the Digest256 value type.