documentation updates, remove superfluous comments

This commit is contained in:
Aaron Po
2026-06-23 01:04:46 -04:00
parent e590cf2543
commit 35a5c0785c
21 changed files with 44 additions and 95 deletions

View File

@@ -2,11 +2,11 @@
#define BIERGARTEN_PIPELINE_INCLUDES_BIERGARTEN_DATA_GENERATOR_H_ #define BIERGARTEN_PIPELINE_INCLUDES_BIERGARTEN_DATA_GENERATOR_H_
/** /**
* @file biergarten_data_generator.h * @file biergarten_pipeline_orchestrator.h
* @brief Orchestration for end-to-end brewery data generation pipeline. * @brief Orchestration for end-to-end brewery and user data generation.
* *
* Intent: Coordinates location loading, enrichment, and generation phases * Coordinates location loading, enrichment, and generation phases to produce
* to produce a complete dataset. Coordinates dependencies via composition root. * a complete dataset, wiring dependencies selected at the composition root.
*/ */
#include <memory> #include <memory>
@@ -20,16 +20,16 @@
#include "services/logging/logger.h" #include "services/logging/logger.h"
/** /**
* @brief Main data generator class for the Biergarten pipeline. * @brief Main orchestrator for the Biergarten data generation pipeline.
* *
* This class encapsulates the core logic for generating brewery data. * Handles location loading, city enrichment, and brewery/user generation.
* It handles location loading, city enrichment, and brewery generation.
*/ */
class BiergartenPipelineOrchestrator { class BiergartenPipelineOrchestrator {
public: public:
/** /**
* @brief Constructs the orchestrator with injected pipeline dependencies. * @brief Constructs the orchestrator with injected pipeline dependencies.
* *
* @param logger Sink for pipeline diagnostics.
* @param context_service Provides regional context for locations. * @param context_service Provides regional context for locations.
* @param generator Implementation (Llama or Mock) for brewery/user * @param generator Implementation (Llama or Mock) for brewery/user
* generation. * generation.
@@ -49,7 +49,7 @@ class BiergartenPipelineOrchestrator {
* Performs the following steps: * Performs the following steps:
* 1. Load curated locations from JSON * 1. Load curated locations from JSON
* 2. Resolve context for each city using the injected context service * 2. Resolve context for each city using the injected context service
* 3. Generate brewery data for sampled cities * 3. Generate brewery and user data for sampled cities
* *
* @note STRUCTURAL CONCURRENCY REQUIREMENT: * @note STRUCTURAL CONCURRENCY REQUIREMENT:
* When transitioned to a multithreaded design, this method MUST * When transitioned to a multithreaded design, this method MUST
@@ -63,35 +63,27 @@ class BiergartenPipelineOrchestrator {
bool Run(); bool Run();
private: private:
/**
* @brief Logger instance for emitting pipeline messages.
*/
std::shared_ptr<ILogger> logger_; std::shared_ptr<ILogger> logger_;
/**
* @brief Owning context provider dependency.
*/
std::unique_ptr<IEnrichmentService> context_service_; std::unique_ptr<IEnrichmentService> context_service_;
/** /**
* @brief Generator dependency selected in the composition root. * @brief Generator implementation selected at the composition root (Llama
* or Mock).
*/ */
std::unique_ptr<DataGenerator> generator_; std::unique_ptr<DataGenerator> generator_;
/** /**
* @brief Storage backend for generated brewery records. * @brief Storage backend for generated brewery and user records.
*/ */
std::unique_ptr<IExportService> exporter_; std::unique_ptr<IExportService> exporter_;
/**
* @brief CLI configuration: paths, model settings, generation parameters.
*/
ApplicationOptions application_options_; ApplicationOptions application_options_;
/** /**
* @brief Load locations from JSON and sample cities. * @brief Load locations from JSON and sample cities.
* *
* @return Vector of sampled locations capped at 50 entries. * @return Vector of locations randomly sampled per
* PipelineOptions::location_count.
*/ */
std::vector<Location> QueryCitiesWithCountries(); std::vector<Location> QueryCitiesWithCountries();
@@ -115,18 +107,11 @@ class BiergartenPipelineOrchestrator {
void GenerateUsers(std::span<const EnrichedCity> cities); void GenerateUsers(std::span<const EnrichedCity> cities);
/** /**
* @brief Log the generated brewery results. * @brief Log the generated brewery and user results.
*/ */
void LogResults() const; void LogResults() const;
/**
* @brief Stores generated brewery data.
*/
std::vector<BreweryRecord> generated_breweries_; std::vector<BreweryRecord> generated_breweries_;
/**
* @brief Stores generated user data.
*/
std::vector<UserRecord> generated_users_; std::vector<UserRecord> generated_users_;
}; };
#endif // BIERGARTEN_PIPELINE_INCLUDES_BIERGARTEN_DATA_GENERATOR_H_ #endif // BIERGARTEN_PIPELINE_INCLUDES_BIERGARTEN_DATA_GENERATOR_H_

View File

@@ -10,6 +10,9 @@
#include <string_view> #include <string_view>
// GBNF grammar for structured user JSON output. // GBNF grammar for structured user JSON output.
// thought-block permits the model to emit free-form reasoning before the
// JSON object (the prompts explicitly invite this); only the "{...}" tail is
// constrained to the expected shape.
inline constexpr std::string_view kUserJsonGrammar = R"json_user( inline constexpr std::string_view kUserJsonGrammar = R"json_user(
root ::= thought-block "{" ws root ::= thought-block "{" ws
"\"username\"" ws ":" ws string ws "," ws "\"username\"" ws ":" ws string ws "," ws
@@ -25,7 +28,8 @@ hex ::= [0-9a-fA-F]
number ::= "-"? ("0" | [1-9] [0-9]*) ("." [0-9]+)? number ::= "-"? ("0" | [1-9] [0-9]*) ("." [0-9]+)?
)json_user"; )json_user";
// GBNF grammar for structured brewery JSON output. // GBNF grammar for structured brewery JSON output (see thought-block note
// above).
inline constexpr std::string_view kBreweryJsonGrammar = R"json_brewery( inline constexpr std::string_view kBreweryJsonGrammar = R"json_brewery(
root ::= thought-block "{" ws root ::= thought-block "{" ws
"\"name_en\"" ws ":" ws string ws "," ws "\"name_en\"" ws ":" ws string ws "," ws

View File

@@ -44,14 +44,9 @@ class LlamaGenerator final : public DataGenerator {
~LlamaGenerator() override; ~LlamaGenerator() override;
// disable copy constructor
LlamaGenerator(const LlamaGenerator&) = delete; LlamaGenerator(const LlamaGenerator&) = delete;
// disable copy assignment operator
LlamaGenerator& operator=(const LlamaGenerator&) = delete; LlamaGenerator& operator=(const LlamaGenerator&) = delete;
// disable move constructor
LlamaGenerator(LlamaGenerator&&) = delete; LlamaGenerator(LlamaGenerator&&) = delete;
// disable move assignment operator
LlamaGenerator& operator=(LlamaGenerator&&) = delete; LlamaGenerator& operator=(LlamaGenerator&&) = delete;
/** /**

View File

@@ -28,14 +28,7 @@ namespace prog_opts = boost::program_options;
* @brief Canonical location record for city-level generation. * @brief Canonical location record for city-level generation.
*/ */
struct Location { struct Location {
/**
* @brief City name.
*/
std::string city{}; std::string city{};
/**
* @brief State or province name.
*/
std::string state_province{}; std::string state_province{};
/** /**
@@ -43,9 +36,6 @@ struct Location {
*/ */
std::string iso3166_2{}; std::string iso3166_2{};
/**
* @brief Country name.
*/
std::string country{}; std::string country{};
/** /**
@@ -79,14 +69,7 @@ struct Location {
* Produced by NamesByCountry::SampleName(); * Produced by NamesByCountry::SampleName();
*/ */
struct Name { struct Name {
/**
* @brief First (given) name.
*/
std::string first_name{}; std::string first_name{};
/**
* @brief Last (family) name.
*/
std::string last_name{}; std::string last_name{};
/** /**
@@ -207,9 +190,6 @@ struct PipelineOptions {
*/ */
std::filesystem::path prompt_dir; std::filesystem::path prompt_dir;
/**
* @brief Path for application logs.
*/
std::filesystem::path log_path; std::filesystem::path log_path;
/** /**

View File

@@ -16,24 +16,10 @@
*/ */
class LlamaBackendState { class LlamaBackendState {
public: public:
/**
* @brief Initializes global llama backend state.
*/
LlamaBackendState() { llama_backend_init(); } LlamaBackendState() { llama_backend_init(); }
/**
* @brief Cleans up global llama backend state.
*/
~LlamaBackendState() { llama_backend_free(); } ~LlamaBackendState() { llama_backend_free(); }
/**
* @brief Non-copyable type.
*/
LlamaBackendState(const LlamaBackendState&) = delete; LlamaBackendState(const LlamaBackendState&) = delete;
/**
* @brief Non-copyable type.
*/
LlamaBackendState& operator=(const LlamaBackendState&) = delete; LlamaBackendState& operator=(const LlamaBackendState&) = delete;
}; };

View File

@@ -16,10 +16,6 @@
class IExportService { class IExportService {
public: public:
IExportService() = default; IExportService() = default;
/**
* @brief Virtual destructor for polymorphic cleanup.
*/
virtual ~IExportService() = default; virtual ~IExportService() = default;
IExportService(const IExportService&) = delete; IExportService(const IExportService&) = delete;

View File

@@ -109,6 +109,8 @@ INSERT INTO users (
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?); ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
)sql"; )sql";
// sqlite3_bind_*() parameter indices are 1-based, matching the "?"
// placeholder order in the SQL above.
inline constexpr int kLocationCityBindIndex = 1; inline constexpr int kLocationCityBindIndex = 1;
inline constexpr int kLocationStateProvinceBindIndex = 2; inline constexpr int kLocationStateProvinceBindIndex = 2;
inline constexpr int kLocationIso31662BindIndex = 3; inline constexpr int kLocationIso31662BindIndex = 3;

View File

@@ -18,9 +18,6 @@
*/ */
class IDateTimeProvider { class IDateTimeProvider {
public: public:
/**
* @brief Virtual destructor for polymorphic cleanup.
*/
virtual ~IDateTimeProvider() = default; virtual ~IDateTimeProvider() = default;
IDateTimeProvider() = default; IDateTimeProvider() = default;

View File

@@ -15,9 +15,6 @@
*/ */
class IEnrichmentService { class IEnrichmentService {
public: public:
/**
* @brief Virtual destructor for polymorphic cleanup.
*/
virtual ~IEnrichmentService() = default; virtual ~IEnrichmentService() = default;
/** /**

View File

@@ -1,13 +1,18 @@
//
// Created by aaronpo on 13/05/2026.
//
#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_MOCK_ENRICHMENT_H_ #ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_MOCK_ENRICHMENT_H_
#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_MOCK_ENRICHMENT_H_ #define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_MOCK_ENRICHMENT_H_
/**
* @file services/enrichment/mock_enrichment.h
* @brief No-op IEnrichmentService used when network enrichment is disabled.
*/
#include <string> #include <string>
#include "enrichment_service.h" #include "enrichment_service.h"
/**
* @brief Enrichment service that returns no context for any location.
*/
class MockEnrichmentService final : public IEnrichmentService { class MockEnrichmentService final : public IEnrichmentService {
public: public:
std::string GetLocationContext(const Location& /*loc*/) override { std::string GetLocationContext(const Location& /*loc*/) override {

View File

@@ -36,7 +36,11 @@ class WikipediaEnrichmentService final : public IEnrichmentService {
std::unique_ptr<WebClient> client_; std::unique_ptr<WebClient> client_;
std::shared_ptr<ILogger> logger_; std::shared_ptr<ILogger> logger_;
/** /**
* @brief Canonical cache for raw Wikipedia query extracts. * @brief Cache for raw Wikipedia query extracts, keyed by query string.
*
* GetLocationContext() always queries "brewing" and reuses "beer in
* {country}" for every city in that country, so caching avoids refetching
* the same extract across locations in a run.
*/ */
std::unordered_map<std::string, std::string> extract_cache_; std::unordered_map<std::string, std::string> extract_cache_;
}; };

View File

@@ -13,9 +13,6 @@
*/ */
class WebClient { class WebClient {
public: public:
/**
* @brief Virtual destructor for polymorphic cleanup.
*/
virtual ~WebClient() = default; virtual ~WebClient() = default;
/** /**

View File

@@ -1,6 +1,6 @@
/** /**
* @file biergarten_pipeline_orchestrator/biergarten_pipeline_orchestrator.cc * @file biergarten_pipeline_orchestrator/biergarten_pipeline_orchestrator.cc
* @brief BiergartenDataGenerator constructor implementation. * @brief BiergartenPipelineOrchestrator constructor implementation.
*/ */
#include "biergarten_pipeline_orchestrator.h" #include "biergarten_pipeline_orchestrator.h"

View File

@@ -1,6 +1,6 @@
/** /**
* @file biergarten_pipeline_orchestrator/generate_breweries.cc * @file biergarten_pipeline_orchestrator/generate_breweries.cc
* @brief BiergartenDataGenerator::GenerateBreweries() implementation. * @brief BiergartenPipelineOrchestrator::GenerateBreweries() implementation.
*/ */
#include <chrono> #include <chrono>

View File

@@ -1,6 +1,6 @@
/** /**
* @file biergarten_pipeline_orchestrator/generate_users.cc * @file biergarten_pipeline_orchestrator/generate_users.cc
* @brief BiergartenDataGenerator::GenerateUsers() implementation. * @brief BiergartenPipelineOrchestrator::GenerateUsers() implementation.
*/ */
#include <cctype> #include <cctype>

View File

@@ -1,6 +1,6 @@
/** /**
* @file biergarten_pipeline_orchestrator/log_results.cc * @file biergarten_pipeline_orchestrator/log_results.cc
* @brief BiergartenDataGenerator::LogResults() implementation. * @brief BiergartenPipelineOrchestrator::LogResults() implementation.
*/ */
#include <boost/json/array.hpp> #include <boost/json/array.hpp>

View File

@@ -1,6 +1,6 @@
/** /**
* @file biergarten_pipeline_orchestrator/query_cities_with_countries.cc * @file biergarten_pipeline_orchestrator/query_cities_with_countries.cc
* @brief BiergartenDataGenerator::QueryCitiesWithCountries() implementation. * @brief BiergartenPipelineOrchestrator::QueryCitiesWithCountries() implementation.
*/ */
#include <algorithm> #include <algorithm>

View File

@@ -1,6 +1,6 @@
/** /**
* @file biergarten_pipeline_orchestrator/run.cc * @file biergarten_pipeline_orchestrator/run.cc
* @brief BiergartenDataGenerator::Run() implementation. * @brief BiergartenPipelineOrchestrator::Run() implementation.
*/ */
#include <chrono> #include <chrono>

View File

@@ -1,5 +1,6 @@
/** /**
* @file wikipedia/fetch_extract.cc * @file wikipedia/fetch_extract.cc
* @brief WikipediaEnrichmentService::FetchExtract() implementation.
*/ */
#include <boost/json.hpp> #include <boost/json.hpp>

View File

@@ -1,6 +1,6 @@
/** /**
* @file wikipedia/get_summary.cc * @file wikipedia/get_summary.cc
* @brief WikipediaService::GetLocationContext() implementation. * @brief WikipediaEnrichmentService::GetLocationContext() implementation.
*/ */
#include <chrono> #include <chrono>

View File

@@ -1,6 +1,6 @@
/** /**
* @file services/wikipedia/wikipedia_service.cc * @file services/wikipedia/wikipedia_service.cc
* @brief WikipediaService constructor implementation. * @brief WikipediaEnrichmentService constructor implementation.
*/ */
#include "services/enrichment/wikipedia_service.h" #include "services/enrichment/wikipedia_service.h"