Conversation
- Created comprehensive plan in copilot/plans/remove_dead_code.md - Broke down plan into 5 actionable tasks in copilot/tasks/remove_dead_code/ - Added remove_dead_code.md instructions - Moved completed conform_project_to_coding_standards.md to completed/ Plan addresses removal of obsolete Threading enum, deprecation of legacy init APIs, cleanup of broken CI steps, and documentation of C API migration.
- Removed entire perf_sample job from .github/workflows/ci_linux.yml - Job referenced non-existent copilot/perf/run_sample.sh script - Only ran on manual workflow_dispatch and never functioned correctly - No copilot/perf/ directory exists in repository Task: 01_remove_perf_sample_ci_step.md (Phase 1 - Low Risk)
Mark legacy global initialization functions as deprecated via @deprecated documentation comments, steering users toward the modern SolverContext API. Changes: - library/src/api/dll.h: Add @deprecated notices to SetMaxThreads, SetThreading, SetResources, FreeMemory with migration guidance - docs/api_migration.md: Create comprehensive migration guide with 3 detailed examples (basic solving, batch processing, multi-threading) - README.md: Add API documentation section with side-by-side comparison of modern C++ vs legacy C API - Task file: Update status to completed Approach: Used @deprecated in Doxygen comments instead of [[deprecated]] attributes due to C API compatibility requirements. C functions with extern "C" linkage cannot reliably use C++11 attributes. All tests pass (28/28). No breaking changes - fully backward compatible. Task: 02_add_deprecation_notices.md Plan: copilot/plans/remove_dead_code.md
Remove legacy threading configuration from test infrastructure now that threading is implicit via SolverContext. This cleans up command-line options and reduces unused configuration paths. Changes: - library/tests/cst.hpp: Remove Threading enum and threading_ field - library/tests/args.cpp: Drop -t/--threading option, threading parsing, usage text, and print output; update option count - library/tests/args.hpp: Remove threading mention from docs - library/tests/itest.cpp and dtest.cpp: Remove SetThreading() call - Task file: Mark Task 03 as completed Validation: - bazel build //library/tests:all --compilation_mode=dbg - bazel test //library/tests:all --compilation_mode=dbg - bazel test //... --compilation_mode=dbg - dtest --help shows no threading option - grep confirms no Threading references Task: 03_remove_threading_enum.md Plan: copilot/plans/remove_dead_code.md
Create legacy C API documentation and add a migration example to clarify how the modern SolverContext API replaces global initialization. Update build system docs with API layering and refresh examples to use the current SolverConfig memory fields. Changes: - docs/legacy_c_api.md: New compatibility and migration document - docs/BUILD_SYSTEM.md: Add API layers section - examples/migration_example.cpp: Side-by-side legacy/modern usage - examples/BUILD.bazel: Add migration_example target - README.md: Link migration example - docs/api_migration.md: Fix SolverConfig field names - Task 04 file: Mark complete Validation: - bazel build //examples:migration_example --compilation_mode=dbg Task: 04_document_c_api_compatibility.md Plan: copilot/plans/remove_dead_code.md
Record Task 05 build, test, smoke test, and example run results. Note missing regression BUILD package and unavailable ASAN/clang-tidy configs on this setup, along with observed calc_dd_table output. Task: 05_final_verification_and_pr.md Plan: copilot/plans/remove_dead_code.md
The calc_single_common function was creating separate SolverContext instances for each declarer when calculating DD tables, causing each declarer to have its own isolated transposition table. This led to inconsistent results between declarers solving the same board. Changes: - Modified calc_single_common to create a single SolverContext and pass it to all solver calls - Updated solve_same_board signature to accept SolverContext& instead of ThreadData pointer, ensuring context reuse - All four declarers now share the same transposition table state, eliminating the inconsistency Verification: - All 28 unit tests pass - No "Difference" output when running dtest with calc mode on 100 hands - Solve mode continues to work correctly
There was a problem hiding this comment.
Pull request overview
This PR combines two distinct sets of changes: (1) a bug fix for DD table calculation consistency by reusing SolverContext across declarers, and (2) removal of legacy threading infrastructure and addition of extensive API migration documentation.
Changes:
- Core bug fix: Modified
calc_single_common()to create a singleSolverContextand reuse it across all four declarers, fixing inconsistent DD table results - Test infrastructure cleanup: Removed obsolete
Threadingenum and-t/--threadingcommand-line options from test harness - API deprecation: Added deprecation notices to legacy C API initialization functions (
SetThreading,SetMaxThreads,SetResources,FreeMemory) - Documentation: Created comprehensive migration guides (
docs/api_migration.md,docs/legacy_c_api.md) with examples showing how to migrate from legacy C API to modern C++ API - CI cleanup: Removed non-functional
perf_samplejob from Linux CI workflow - Examples: Added
migration_example.cppdemonstrating both legacy and modern API usage patterns
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| library/src/calc_tables.cpp | Creates single SolverContext and passes to both SolveBoard and solve_same_board for consistency |
| library/src/solver_if.hpp | Changes solve_same_board signature from ThreadData pointer to SolverContext reference |
| library/src/solver_if.cpp | Refactored to accept and reuse provided SolverContext instead of creating new one |
| library/tests/cst.hpp | Removed Threading enum definition and threading_ field from OptionsType |
| library/tests/args.cpp | Removed threading option parsing logic and updated help text |
| library/tests/args.hpp | Updated documentation to remove threading model references |
| library/tests/dtest.cpp | Removed SetThreading() initialization call |
| library/tests/itest.cpp | Removed SetThreading() initialization call |
| library/src/api/dll.h | Added deprecation notices to legacy initialization functions |
| examples/migration_example.cpp | New example showing side-by-side legacy and modern API usage |
| examples/BUILD.bazel | Added migration_example build target |
| docs/api_migration.md | New comprehensive migration guide with detailed examples |
| docs/legacy_c_api.md | New documentation of C API compatibility strategy |
| docs/BUILD_SYSTEM.md | Added API layers section |
| README.md | Added API documentation overview with quick examples |
| .github/workflows/ci_linux.yml | Removed broken perf_sample CI job |
| copilot/* | Planning and task tracking documentation for the dead code removal work |
copilot/tasks/remove_dead_code/04_document_c_api_compatibility.md
Outdated
Show resolved
Hide resolved
- Fix SolverConfig field name references in docs and deprecation notice - Correct indentation in solve_same_board - Update verification notes for calc smoke test
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 25 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
examples/migration_example.cpp:46
- This new example doesn’t match the conventions used by the other files in examples/: they consistently use trailing return types for main (e.g., examples/solve_board.cpp:21 uses
auto main() -> int) and a different indentation style. Aligning migration_example.cpp with the existing examples will keep the examples directory consistent.
{
Deal deal{};
solve_legacy(deal);
solve_modern(deal);
return 0;
}
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Use simpler SolverContext(cfg) constructor throughout all examples - Improve SetMaxThreads deprecation notice to clarify threading model - Update comment in calc_tables.cpp to mention TransTable reuse - Fix include order in migration_example.cpp - Simplify README.md example to be more self-contained - Apply consistent constructor pattern across all documentation All tests pass (28/28)
- Use auto main() -> int in migration_example.cpp for consistency - Update field names in completed plan doc to match actual SolverConfig
…tices.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…patibility.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| for (int k = 1; k < DDS_HANDS; k++) | ||
| { | ||
| int hint = (k == 2 ? fut.score[0] : 13 - fut.score[0]); | ||
|
|
||
| deal.first = k; // Next declarer |
There was a problem hiding this comment.
The per-declarer loop computes hint from fut.score[0] and calls solve_same_board() even if the initial SolveBoard() call failed. Since FutureTricks fut is not value-initialized, this can read garbage and lead to undefined behavior. Consider returning early / skipping the loop when res != 1, and/or value-initialize fut before first use.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Initialize FutureTricks fut with {} to avoid undefined behavior if first solve fails
- Extend context reuse comment to explicitly mention consistency bug fix
- Ensures proper zero-initialization of fut structure
Summary
Primary objective: remove legacy threading dead code and document the modern API.
This PR:
Rationale
The dead-code cleanup and documentation were the main goals of this PR. During verification, an unrelated calc consistency bug surfaced, so a targeted fix is included here to keep verification accurate.
Verification
dtest -f hands/list100.txt -s calc -n 1shows no Difference outputdtest -f hands/list100.txt -s solve -n 4passesFiles Changed
library/src/calc_tables.cpplibrary/src/solver_if.cpplibrary/src/solver_if.hpplibrary/src/api/dll.hlibrary/tests/*(threading option removal)docs/*andexamples/*(migration guidance).github/workflows/ci_linux.ymlcopilot/*(task tracking)