Skip to content

[WIP] Fix CMake linking for themis_core with target validation - #4

Closed
makr-code with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-cmake-target-linking
Closed

makr-code with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-cmake-target-linking

Conversation

Copilot AI commented Nov 6, 2025 •

Copy link
Copy Markdown
Contributor
  • Review the current CMakeLists.txt structure and locate the target_link_libraries block (lines 224-238)
  • Replace the fragile direct linking block with defensive resolution of ambiguous targets
  • Add validation for Arrow targets (Arrow::arrow_shared or Arrow::arrow)
  • Add validation for all required targets before linking
  • Keep optional behavior unchanged (ZSTD, faiss/hnsw, OpenTelemetry)
  • Test the changes to ensure CMake configuration works correctly
  • Request code review before finalizing
Original prompt

The CI job for the repository fails during CMake configure with the error: "Target "themis_core" links to: * An ALIAS target is missing." This is caused by a target_link_libraries call in CMakeLists.txt that attempts to link imported/ALIAS targets which may not exist (different packages can export different target names). Replace the fragile direct linking block with defensive resolution of ambiguous targets (Arrow), validate each required imported target before linking, and keep the existing optional behavior (ZSTD, faiss/hnsw, OpenTelemetry) unchanged.

Change file: CMakeLists.txt (ref: f7e70cc)

Detailed changes to make:

  1. Replace the existing target_link_libraries(themis_core ...) block around line 224 with the following code that:
    • selects Arrow::arrow_shared or Arrow::arrow depending on availability
    • collects all required targets in a list
    • validates each target with if(NOT TARGET ...) and emits a clear message(FATAL_ERROR) naming the missing target
    • links the validated targets
    • leaves ZSTD, GPU/hnsw, and OpenTelemetry logic intact

Code to insert (exact):

--- Defensive resolution of potentially ambiguous targets ---

Arrow may export Arrow::arrow_shared or Arrow::arrow depending on packaging

if(TARGET Arrow::arrow_shared)
set(THEMIS_ARROW_TARGET Arrow::arrow_shared)
elseif(TARGET Arrow::arrow)
set(THEMIS_ARROW_TARGET Arrow::arrow)
else()
message(FATAL_ERROR "Required CMake target 'Arrow::arrow_shared' or 'Arrow::arrow' not found. Ensure Arrow was found correctly.")
endif()

Collect required targets (OpenSSL targets are included here as well)

set(THEMIS_REQUIRED_TARGETS
RocksDB::rocksdb
simdjson::simdjson
TBB::tbb
${THEMIS_ARROW_TARGET}
fmt::fmt
spdlog::spdlog
Boost::system
nlohmann_json::nlohmann_json
CURL::libcurl
yaml-cpp::yaml-cpp
OpenSSL::SSL
OpenSSL::Crypto
)

Validate that each required target actually exists and provide a clear error if not

foreach(_tgt IN LISTS THEMIS_REQUIRED_TARGETS)
if(NOT TARGET ${_tgt})
message(FATAL_ERROR "Required CMake target '${_tgt}' not found for target 'themis_core'. Ensure the corresponding package was found and provides this target.")
endif()
endforeach()

Link the validated targets

target_link_libraries(themis_core
PUBLIC
${THEMIS_REQUIRED_TARGETS}
)

Link ZSTD if available and define compile flag (unchanged)

if(DEFINED THEMIS_ZSTD_TARGET)
target_link_libraries(themis_core PUBLIC ${THEMIS_ZSTD_TARGET})
target_compile_definitions(themis_core PUBLIC THEMIS_HAS_ZSTD)
endif()

GPU / Faiss / hnswlib handling (unchanged)

if(THEMIS_ENABLE_GPU)
target_link_libraries(themis_core PUBLIC faiss)
target_compile_definitions(themis_core PUBLIC THEMIS_GPU_ENABLED)
elseif(hnswlib_FOUND)
target_link_libraries(themis_core PUBLIC hnswlib::hnswlib)
target_compile_definitions(themis_core PUBLIC THEMIS_HNSW_ENABLED)
endif()

Tracing: keep the existing defensive checks for OpenTelemetry targets

if(THEMIS_ENABLE_TRACING)
if(NOT TARGET opentelemetry-cpp::trace)
message(FATAL_ERROR "Required CMake target 'opentelemetry-cpp::trace' not found. Ensure opentelemetry-cpp was found successfully.")
endif()
if(NOT TARGET opentelemetry-cpp::otlp_http_exporter)
message(FATAL_ERROR "Required CMake target 'opentelemetry-cpp::otlp_http_exporter' not found. Ensure opentelemetry-cpp was found successfully with otlp-http feature.")
endif()

target_link_libraries(themis_core PUBLIC
    opentelemetry-cpp::trace
    opentelemetry-cpp::otlp_http_exporter
)
target_compile_definitions(themis_core PUBLIC THEMIS_ENABLE_TRACING)

endif()

Notes:

  • This change fails early and explicitly naming missing imported targets, so the CI will report which dependency is not providing the expected target name.
  • No functional changes to optional features; only moves linking into a validated flow.

Please create a branch, apply the change, and open a pull request with a descriptive title and body referencing the CI failure (Actions run id: 19145420362, job id: 54721635820).

This pull request was created as a result of the following prompt from Copilot chat.

The CI job for the repository fails during CMake configure with the error: "Target "themis_core" links to: * An ALIAS target is missing." This is caused by a target_link_libraries call in CMakeLists.txt that attempts to link imported/ALIAS targets which may not exist (different packages can export different target names). Replace the fragile direct linking block with defensive resolution of ambiguous targets (Arrow), validate each required imported target before linking, and keep the existing optional behavior (ZSTD, faiss/hnsw, OpenTelemetry) unchanged.

Change file: CMakeLists.txt (ref: f7e70cc)

Detailed changes to make:

  1. Replace the existing target_link_libraries(themis_core ...) block around line 224 with the following code that:
    • selects Arrow::arrow_shared or Arrow::arrow depending on availability
    • collects all required targets in a list
    • validates each target with if(NOT TARGET ...) and emits a clear message(FATAL_ERROR) naming the missing target
    • links the validated targets
    • leaves ZSTD, GPU/hnsw, and OpenTelemetry logic intact

Code to insert (exact):

--- Defensive resolution of potentially ambiguous targets ---

Arrow may export Arrow::arrow_shared or Arrow::arrow depending on packaging

if(TARGET Arrow::arrow_shared)
set(THEMIS_ARROW_TARGET Arrow::arrow_shared)
elseif(TARGET Arrow::arrow)
set(THEMIS_ARROW_TARGET Arrow::arrow)
else()
message(FATAL_ERROR "Required CMake target 'Arrow::arrow_shared' or 'Arrow::arrow' not found. Ensure Arrow was found correctly.")
endif()

Collect required targets (OpenSSL targets are included here as well)

set(THEMIS_REQUIRED_TARGETS
RocksDB::rocksdb
simdjson::simdjson
TBB::tbb
${THEMIS_ARROW_TARGET}
fmt::fmt
spdlog::spdlog
Boost::system
nlohmann_json::nlohmann_json
CURL::libcurl
yaml-cpp::yaml-cpp
OpenSSL::SSL
OpenSSL::Crypto
)

Validate that each required target actually exists and provide a clear error if not

foreach(_tgt IN LISTS THEMIS_REQUIRED_TARGETS)
if(NOT TARGET ${_tgt})
message(FATAL_ERROR "Required CMake target '${_tgt}' not found for target 'themis_core'. Ensure the corresponding package was found and provides this target.")
endif()
endforeach()

Link the validated targets

target_link_libraries(themis_core
PUBLIC
${THEMIS_REQUIRED_TARGETS}
)

Link ZSTD if available and define compile flag (unchanged)

if(DEFINED THEMIS_ZSTD_TARGET)
target_link_libraries(themis_core PUBLIC ${THEMIS_ZSTD_TARGET})
target_compile_definitions(themis_core PUBLIC THEMIS_HAS_ZSTD)
endif()

GPU / Faiss / hnswlib handling (unchanged)

if(THEMIS_ENABLE_GPU)
target_link_libraries(themis_core PUBLIC faiss)
target_compile_definitions(themis_core PUBLIC THEMIS_GPU_ENABLED)
elseif(hnswlib_FOUND)
target_link_libraries(themis_core PUBLIC hnswlib::hnswlib)
target_compile_definitions(themis_core PUBLIC THEMIS_HNSW_ENABLED)
endif()

Tracing: keep the existing defensive checks for OpenTelemetry targets

if(THEMIS_ENABLE_TRACING)
if(NOT TARGET opentelemetry-cpp::trace)
message(FATAL_ERROR "Required CMake target 'opentelemetry-cpp::trace' not found. Ensure opentelemetry-cpp was found successfully.")
endif()
if(NOT TARGET opentelemetry-cpp::otlp_http_exporter)
message(FATAL_ERROR "Required CMake target 'opentelemetry-cpp::otlp_http_exporter' not found. Ensure opentelemetry-cpp was found successfully with otlp-http feature.")
endif()

target_link_libraries(themis_core PUBLIC
    opentelemetry-cpp::trace
    opentelemetry-cpp::otlp_http_exporter
)
target_compile_definitions(themis_core PUBLIC THEMIS_ENABLE_TRACING)

endif()

Notes:

  • This change fails early and explicitly naming missing imported targets, so the CI will report which dependency is not providing the expected target name.
  • No functional changes to optional features; only moves linking into a validated flow.

Please create a branch, apply the change, and open a pull request with a descriptive title and body referencing the CI failure (Actions run id: 19145420362, job id: 54721635820).


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@makr-code makr-code closed this Nov 6, 2025
Copilot AI requested a review from makr-code November 6, 2025 19:53
@makr-code
makr-code deleted the copilot/fix-cmake-target-linking branch November 30, 2025 11:50
Copilot AI added a commit that referenced this pull request Dec 22, 2025
… Write Buffer optimization docs

Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request Jan 5, 2026
…tegration with comprehensive tests and benchmarks

Co-authored-by: makr-code <[email protected]>
@makr-code makr-code added this to the Phase 1: Core CUDA Implementation milestone Feb 21, 2026
@makr-code makr-code added this to the v1.0.2 milestone Mar 11, 2026
Copilot AI added a commit that referenced this pull request Mar 11, 2026
…umentation

- Update ROADMAP.md: mark Distributed API Gateway as [x] done (v2.1.0)
- Add distributed_gateway.h section to include/server/README.md
- Update docs/de/server/missing-implementations.json: move finding #4 to verified_implemented
- Update docs/de/server/missing-implementations.md: mark finding #4 fully resolved
- Create docs/DISTRIBUTED_GATEWAY.md: comprehensive feature documentation

Co-authored-by: makr-code <[email protected]>
@makr-code makr-code mentioned this pull request Mar 12, 2026
9 tasks
Copilot AI added a commit that referenced this pull request Mar 23, 2026
…ntFramework + MurmurHash3 + Welch t-test (v1.9.0)

- PromptABExperimentFramework: public A/B framework, deterministic MurmurHash3-32 variant assignment
- Welch two-sample t-test + Welch-Satterthwaite df for auto-promotion
- ExperimentVariant/ExperimentContext/ExperimentStatus/PromptExperiment/ExperimentOutcome/ExperimentSummary
- Exception-safe WinnerCallback
- 30 tests, CI: prompt-ab-experiment-ci.yml
- CHANGELOG [1.9.0], ROADMAP Phase 5 item 3 done, FUTURE_ENHANCEMENTS ✅
- German docs + missing-implementations.md item #4 resolved

Co-authored-by: makr-code <[email protected]>
Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/7c9b7c61-067c-4816-8238-8b423c0e3eaf
Copilot AI added a commit that referenced this pull request Apr 7, 2026
- TODO #1: Add idle-timeout background thread to TumblingWindow and
  SlidingWindow (idleTimeoutLoop). When no events arrive for
  idle_timeout duration the watermark is advanced to now minus
  max_out_of_orderness and expired windows are closed and emitted.
  Tracks last_event_us_ atomically; thread started only when
  idle_timeout > 0ms; stopped safely before state teardown.

- TODO #2: Store partition_key in TumblingWindow::InternalWindow and
  SlidingWindow::InternalWindow. Set on window creation from the
  creating record's partition_key. Propagate to WindowResult in
  computeResult(). Update SlidingWindow::ensureWindowsExist signature
  to accept const std::string& partition_key.

- TODO #3: Track Session::has_late_records (default false). Set to
  true whenever a late record (ev_us < wm with allow_late_data) is
  added to a session in ingest(). Pass to computeResult() in
  ingest(), flush(), and expiryLoop() so is_late_firing is correctly
  set on timer-driven and gap-triggered session closures.

- TODO #4: Add session_expiry_interval_ms to
  StreamingWindowPipeline::Config. Update session() factory to accept
  optional expiry_interval_ms parameter. Forward to
  SessionWindowConfig::session_expiry_check_interval_ms in build().

- TODO #5: Replace O(N) inner loop in SlidingWindow::ensureWindowsExist
  and HoppingWindow::ensureWindowsExist with
  unordered_set<int64_t> window_start_set_ for O(1) duplicate
  detection. Keep set in sync on window creation and pruning in
  closeExpiredWindows().

- TODO #7: SessionWindow::computeResult() now accepts bool late = false
  and sets r.is_late_firing = late. All call-sites in ingest(),
  flush(), and expiryLoop() pass s.has_late_records.

- TODO #8: RESOLVED (no code change needed) — closeExpiredWindows()
  duplicate results on shutdown.

Co-authored-by: Copilot <[email protected]>

Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request Apr 13, 2026
- Add tools/check_bench_targets.py: standalone guard that detects bench_*.cpp
  files without CMake target coverage. A source is covered by either an explicit
  add_executable() entry or the THEMIS_AUTO_REGISTER_ELIGIBLE_BENCHMARKS block.
  Supports --strict mode (requires explicit targets), --format json, --no-color.

- Add tools/perf_expectations_audit.py: audit orchestrator with STATUS_FAIL checks:
  * Check 8a: orphaned_sources == [] (PASS: 81 auto-registered, 0 orphaned)
  * Check 8b: tools/check_bench_targets.py exists (PASS)

- Add .github/workflows/05-quality_build_bench-source-guard-ci.yml: CI workflow
  that runs both tools on PR/push/schedule. Fails hard on new orphaned sources.

Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/6b5afc19-3345-4f0c-bb3f-a8f172edbe9a

Co-authored-by: makr-code <[email protected]>
makr-code added a commit that referenced this pull request Apr 13, 2026
)

- Add tools/check_bench_targets.py: standalone guard that detects bench_*.cpp
  files without CMake target coverage. A source is covered by either an explicit
  add_executable() entry or the THEMIS_AUTO_REGISTER_ELIGIBLE_BENCHMARKS block.
  Supports --strict mode (requires explicit targets), --format json, --no-color.

- Add tools/perf_expectations_audit.py: audit orchestrator with STATUS_FAIL checks:
  * Check 8a: orphaned_sources == [] (PASS: 81 auto-registered, 0 orphaned)
  * Check 8b: tools/check_bench_targets.py exists (PASS)

- Add .github/workflows/05-quality_build_bench-source-guard-ci.yml: CI workflow
  that runs both tools on PR/push/schedule. Fails hard on new orphaned sources.

Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/6b5afc19-3345-4f0c-bb3f-a8f172edbe9a

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: makr-code <[email protected]>
makr-code added a commit that referenced this pull request Apr 15, 2026
…ck (Maßnahme #4) (#4659)

* Initial plan

* fix(audit): update check_measure_4 to verify CI workflow and mark ERLEDIGT

Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/081e3cd3-8785-4c98-bd2e-1c6042367339

Co-authored-by: makr-code <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request Apr 19, 2026
…rce code

- analytics/README.md: add streaming_join.cpp to interface table; note
  SARIMA/PROPHET are enum-defined but not yet implemented in forecasting.cpp
- analytics/ARCHITECTURE.md: same forecasting clarification; add
  streaming_join.cpp row; update Known Limitations (AutoML/SARIMA status)
- analytics/AUDIT.md: fix test paths to tests/analytics/; update findings
  with Evidence: file:line format per AUDIT.md rules
- analytics/ROADMAP.md: correct AutoMLEngine → AutoML class name; add note
  that SARIMA/PROPHET enum values exist but switch-case handlers are missing

- prompt_engineering/ARCHITECTURE.md: add all 23 implemented components to
  Key Components table; update Known Limitations (token counting now provided
  via ContextWindowBudgetManager)
- prompt_engineering/AUDIT.md: close OI-01..OI-04 (all implemented)
- prompt_engineering/CHANGELOG.md: remove already-implemented items from
  Unreleased; merge duplicate [2.0.0] header into single release block
- prompt_engineering/SECURITY.md: update Supported Versions (2.0.x active);
  correct KL-01 (ContextWindowBudgetManager exists; approximation noted)

- rpc_grpc/README.md: update version 0.0.1 → 0.2.0; add BidiStreamAdapter
  to Component Table
- rpc_grpc/ARCHITECTURE.md: update version/date; add BidiStreamAdapter class
  row; fix Known Limitations (uptime tracking done; reloadTls implemented)
- rpc_grpc/SECURITY.md: fix GRPC-SEC-01 (hot-reload IS implemented in v0.2.0;
  only existing-session renegotiation is by-design limitation)
- rpc_grpc/FUTURE_ENHANCEMENTS.md: mark BidiStreamAdapter (#3) and TLS
  Hot-Reload (#4) as ✅ Implemented (v0.2.0)
- src/rpc_grpc/grpc_plugin.cpp: fix getVersion() return value from "1.0.0"
  to "2.0.0" to match CHANGELOG v0.2.0 entry and test expectation

Co-authored-by: Copilot <[email protected]>

Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request May 26, 2026
…lora_training_service

- data_race #1: Replace TOCTOU (load+store) on is_training_ with
  compare_exchange_strong (atomic claim)
- data_race #2-3: Add metrics_mutex_ to protect current_metrics_,
  loss_history_, current_adapter_id_, training_callback_ in all
  read/write paths (getMetrics, registerCallback, training loop,
  saveCheckpoint, loadCheckpoint, GPU callback)
- data_race #4-5: Add config_mutex_ to setTrainingConfig,
  getTrainingConfig, setHyperparameters, getHyperparameters; training
  loop takes a local Config snapshot at entry so it never races with
  external callers
- data_race #6: Phi-3 detection mutates local_config snapshot only,
  never touches shared config_
- data_race #7 (GPU): trainWithQuantization GPU callback now writes
  current_metrics_ and reads training_callback_ under metrics_mutex_
- iterator_invalidation: loss_history_.push_back and saveCheckpoint
  vector copy both guarded by metrics_mutex_
- no_timeout #1: stopTraining spin-loop replaced with condition_variable
  wait_for (30 s); on timeout is_training_ force-cleared
- no_timeout #2: training thread stores is_training_=false under
  stop_mutex_ then notify_all for correct happens-before with waiter
- tests: add 4 focused concurrency tests (concurrent getMetrics,
  stop clears flag, concurrent registerCallback, concurrent train
  serialisation)
- docs: update src/llm/MODULE_GAPS.md with W1-L02 gap delta (10 findings
  resolved)

Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/12047fc4-4373-4486-9917-d40ec122bea2

Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request Aug 15, 2026
Add comprehensive test suite for Phase 5 C++ safety fixes:

1. test_index_destructor_safety.cpp (338 lines, 10 tests)
   - VectorIndexManager destructor exception handling
   - GPUVectorIndex destructor exception safety
   - Noexcept verification (static_assert)
   - HNSW resource cleanup validation
   - Tests: destructor no-throw, exception during shutdown, stack unwinding,
     multiple calls, concurrent destruction, GPU variants

2. test_index_iterator_validity.cpp (411 lines, 10 tests)
   - Snapshot pattern validation for iterator safety
   - Partition removal stress tests (500+ partitions)
   - Concurrent add/remove patterns (TSan validation)
   - Data operations concurrent with partition removal
   - Tests: safe removal, stress, concurrent access, interleaved patterns,
     snapshot semantics, edge cases (empty, duplicates)

3. test_index_gpu_memory_safety.cpp (458 lines, 10 tests)
   - GPU resource allocation/deallocation pairing (RAII)
   - Memory leak detection across init/destroy cycles
   - Exception safety during GPU initialization
   - Large allocation handling near GPU memory limits
   - Tests: basic allocation, leak detection, exception cleanup, large allocations,
     concurrent management, explicit shutdown, idempotency, state validation

CMakeLists.txt Updates:
- Auto-discovery of test_index_*.cpp files preserved
- Conditional CUDA linkage for GPU tests when THEMIS_CUDA_ENABLED=ON
- Proper test registration via themis_register_module_focused_test()

Validation Coverage:
✓ 30 comprehensive tests (10 per test file)
✓ Exception safety (try/catch scenarios)
✓ RAII patterns (noexcept destructors)
✓ Memory safety (allocation/deallocation tracking)
✓ Concurrency (TSan-compatible multi-threaded tests)
✓ Edge cases (empty, large scale, duplicate operations)
✓ Timeout: 120s per test (reasonable for Phase 5 workloads)

Build Integration:
- Compile: cmake --build . -j 16 (automatically discovered)
- Run: ctest -R "test_index_(destructor|iterator|gpu)" --output-on-failure
- Sanitizers: Built-in support for ASan/TSan/UBSan
- No additional dependencies beyond existing test infrastructure

Fixes Phase 5 Blocker #6 (MEDIUM) by providing regression test coverage
for fixes #1-4:
  Fix #1: VectorIndexManager::~VectorIndexManager() noexcept (line 94)
  Fix #2: releaseHnswResources_() helper for safe cleanup (line 304)
  Fix #3: GPUVectorIndex::~GPUVectorIndex() noexcept (line 121)
  Fix #4: Iterator invalidation fix via snapshot pattern (line 107)

All tests are production-ready and CI/CD compatible.

Co-authored-by: makr-code <[email protected]>
Copilot AI added a commit that referenced this pull request Aug 17, 2026
…critical gate, integrate SRG benchmarks

BLOCKER_FIX_1: Add release_critical label to SCR-01..16 tests
  - File: tests/sharding/CMakeLists.txt:421
  - Enables fail-closed verification in Wave A gate

BLOCKER_FIX_2: Add Wave A Release-Critical CI verification step
  - File: .github/workflows/ci-build.yml (new step after main ctest)
  - Runs 108 release_critical tests (TXC/FLR/FI/SCR suites)
  - Expected runtime: ~5-10 min
  - Verifies Wave A exit criterion #3

BLOCKER_FIX_3: Integrate SRG-01..06 benchmarks in CI pipeline
  - File: .github/workflows/ci-benchmarks.yml (new sharding-release-gates job)
  - Runs all 6 Wave A baseline benchmarks
  - Validates p95/p99 against thresholds
  - Expected runtime: ~20-30 min
  - Verifies Wave A exit criterion #4

All fixes ready for immediate deployment to develop branch.

Co-authored-by: makr-code <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants