How fenndd/bachelorsproject works
1. Project purpose and scope
This repository is a scaffold for automating optimization of C++ 3D vision algorithms with LLM assistance. The first concrete use case is a P3P solver, so the architecture is centered on running, comparing, and eventually modifying C++ solver variants.
2. Two main runtime domains
The system is split into a C++ algorithm layer and a Python orchestration layer. C++ contains the actual solver code and buildable baseline executable; Python coordinates build/run/analysis workflows around that executable.
3. C++ core and baseline boundary
cpp/src/baseline_runner.cpp is the project-owned baseline entry point. It is linked against the imported third-party Lambda Twist P3P implementation under cpp/external/lambdatwist/, which acts as the clean external baseline and should remain unchanged in the current baseline state.
4. Build and native tooling
cpp/CMakeLists.txt defines the native build boundary. The C++ tree also includes placeholders for tests/ and bench/, indicating that validation and benchmarking are intended to be native concerns, even though the README says those stages are not yet fully implemented.
5. Orchestration layer as control plane
The Python package under orchestrator/ is the control plane for experiments. The current entry point is orchestrator/cli/main.py, which the README describes as the minimal CLI for baseline configure/build/run automation.
6. Execution subsystem
orchestrator/execution/ separates the external process steps into distinct runners: build_runner.py, test_runner.py, and benchmark_runner.py. This is the boundary where the Python side invokes native tooling and captures outcomes from CMake/build/test/benchmark operations.
7. Optimization workflow scaffolding
orchestrator/llm/, orchestrator/patching/, and orchestrator/pipeline/ define the future optimization loop. prompt_builder.py and base_adapter.py suggest a provider-agnostic LLM interface, while apply_patch.py is the mechanism for turning generated edits into modified source trees inside the workspace.
8. Experiment state, persistence, and selection
orchestrator/storage/ holds run metadata and result bookkeeping (result_store.py, run_index.py), while orchestrator/analysis/select_best.py indicates post-run ranking or winner selection. This creates a separation between transient execution data and persistent experiment history.
9. Workspace and results as environment boundaries
The repository uses workspace/ for ephemeral run-specific files and results/ for durable outputs. That separation is important architecturally: source-controlled code remains clean, while generated patches, build artifacts, and experiment outputs are isolated from the repo state.
10. Configuration-driven experiments
configs/defaults/, configs/models/, and configs/experiments/ provide a config hierarchy for defaults, model settings, and experiment definitions. This implies runs are intended to be parameterized rather than hardcoded, with configuration files driving orchestration behavior.
11. Documentation and roadmap as architectural contract
docs/architecture.md, docs/baseline.md, docs/setup.md, and docs/roadmap.md document the intended system boundaries and current implementation status. The README makes clear that baseline integration exists, while validation, benchmarking, and the optimization loop are scaffolded but not yet complete.
12. Overall data flow
The practical flow is: configuration in configs/ → Python CLI in orchestrator/cli/ → build/run via orchestrator/execution/ against the C++ baseline in cpp/ → outputs written to workspace/ and persisted in results/ → analysis/reporting via orchestrator/analysis/ and orchestrator/reporting/. The future LLM-assisted loop will insert patch generation and code modification between analysis and execution.
Main entry points: run_pipeline.py Pipeline · baseline_runner.cpp Baseline runner · main.py CLI · build_runner.py Build runner
Components 26
C++ core
Native solver and build boundary
- CMake · Defines the native build boundary for the C++ solver
cpp/CMakeLists.txt - Baseline runner · Project-owned executable entry point for the baseline solver
cpp/src/baseline_runner.cpp - LambdaTwist · Imported external P3P implementation used as the clean baseline
cpp/external/lambdatwist/p3p.cc - P3P API · Header boundary for the external P3P implementation
cpp/external/lambdatwist/p3p.h - Upstream test · Reference test for the imported LambdaTwist implementation
cpp/external/lambdatwist/p3p_test.cc
Python orchestration
Experiment control plane and workflow stages
- CLI · Minimal command-line entry for baseline and experiment automation
orchestrator/cli/main.py - Pipeline · Coordinates end-to-end experiment runs
orchestrator/pipeline/run_pipeline.py - Build runner · Invokes native build steps through the Python control plane
orchestrator/execution/build_runner.py - Test runner · Runs validation steps against built solver artifacts
orchestrator/execution/test_runner.py - Benchmark runner · Runs performance measurements for solver variants
orchestrator/execution/benchmark_runner.py - LLM adapter · Provider-agnostic abstraction for model calls
orchestrator/llm/base_adapter.py - Prompt builder · Builds prompts for optimization and patch generation
orchestrator/llm/prompt_builder.py - Patch applier · Applies generated edits into the workspace
orchestrator/patching/apply_patch.py - Result store · Persists run metadata and outcomes
orchestrator/storage/result_store.py - Run index · Tracks experiment runs and their identifiers
orchestrator/storage/run_index.py - Best select · Ranks results and selects the best candidate
orchestrator/analysis/select_best.py - Report gen · Generates human-readable experiment reports
orchestrator/reporting/generate_report.py
Config and state
Parameterization, workspace, and results
- Defaults · Baseline project defaults for experiments and runs
configs/defaults/project_defaults.yaml - Model config · Model-specific settings for LLM-assisted workflows
configs/models/example_model.yaml - Experiment config · Concrete experiment definition driving orchestration
configs/experiments/example_experiment.yaml - Workspace · Scratch space for run-specific files and modified trees
workspace/.gitkeep - Results · Durable outputs and experiment artifacts
results/.gitkeep
Docs
Architecture and project guidance
- Architecture doc · Explains repository boundaries and design intent
docs/architecture.md - Baseline doc · Documents the current baseline state and solver boundary
docs/baseline.md - Setup doc · Describes environment setup and local usage
docs/setup.md - Roadmap · Tracks intended future capabilities and incomplete stages
docs/roadmap.md
Connections 30
- CMake → Baseline runner: builds · Native build produces the baseline executable
- Baseline runner → LambdaTwist: links to · Project-owned entry point wraps the imported solver
- Baseline runner → P3P API: uses API · Baseline runner depends on the external solver interface
- LambdaTwist → Upstream test: validated by · Imported implementation includes its own reference test
- Experiment config → CLI: drives · Experiment definitions are consumed by the CLI and pipeline
- Defaults → CLI: sets defaults · Project defaults parameterize orchestration behavior
- Model config → LLM adapter: configures · Model settings feed the provider-agnostic adapter
- CLI → Pipeline: invokes · CLI hands control to the experiment pipeline
- Pipeline → Build runner: runs · Pipeline stages invoke the native build runner
- Pipeline → Test runner: runs · Pipeline stages invoke validation after build
- Pipeline → Benchmark runner: runs · Pipeline stages can benchmark solver variants
- Build runner → CMake: calls · Build runner executes the CMake-defined native build
- Test runner → Baseline runner: executes · Test runner runs the built baseline or variants
- Benchmark runner → Baseline runner: measures · Benchmarking targets the solver executable
- Pipeline → LLM adapter: queries · Optimization loop requests model assistance
- LLM adapter → Prompt builder: uses · Adapter relies on prompt construction for requests
- Pipeline → Patch applier: applies edits · Generated changes are materialized into the workspace
- Patch applier → Workspace: writes · Patch application updates ephemeral run files
- Build runner → Workspace: builds in · Native builds are staged inside the workspace boundary
- Test runner → Results: records · Validation outcomes are persisted as experiment outputs
- Benchmark runner → Results: records · Benchmark outputs are stored for later comparison
- Pipeline → Result store: persists · Pipeline stores run metadata and outcomes
- Result store → Run index: indexes · Persistent storage is organized by run identifiers
- Result store → Best select: feeds · Stored results are used for winner selection
- Best select → Report gen: summarizes · Selected results are turned into reports
- Report gen → Results: publishes · Reports are emitted into the durable results area
- Architecture doc → Pipeline: describes · Documentation captures the orchestration architecture
- Baseline doc → Baseline runner: describes · Baseline documentation explains the solver boundary
- Setup doc → CLI: guides · Setup instructions support local orchestration usage
- Roadmap → Patch applier: projects · Roadmap calls out future optimization and patching work