Skip to content

Fix shard-summary routing precedence for invalid summaries #24

Fix shard-summary routing precedence for invalid summaries

Fix shard-summary routing precedence for invalid summaries #24

name: "Gate: Module Validation [distributed_knowledge]"
# Rechenaufwand-Score: R=3 (K=3, L=3, N=3) | last-calibrated: 2026-08-25
# Trigger policy: repo framework score calibration for workflow cost controls.
# This workflow validates the distributed_knowledge module gap closure
# Triggered on changes to the implementation branch
on:
push:
branches:
- copilot/implement-gaps-closing-again
paths:
- 'src/distributed_knowledge/**/*.c'
- 'src/distributed_knowledge/**/*.cc'
- 'src/distributed_knowledge/**/*.cpp'
- 'src/distributed_knowledge/**/*.cxx'
- 'src/distributed_knowledge/**/*.h'
- 'src/distributed_knowledge/**/*.hh'
- 'src/distributed_knowledge/**/*.hpp'
- 'src/distributed_knowledge/**/*.hxx'
- 'include/distributed_knowledge/**/*.h'
- 'include/distributed_knowledge/**/*.hh'
- 'include/distributed_knowledge/**/*.hpp'
- 'include/distributed_knowledge/**/*.hxx'
- 'tests/**/*distributed_knowledge*.c'
- 'tests/**/*distributed_knowledge*.cc'
- 'tests/**/*distributed_knowledge*.cpp'
- 'tests/**/*distributed_knowledge*.cxx'
- 'tests/**/*distributed_knowledge*.h'
- 'tests/**/*distributed_knowledge*.hh'
- 'tests/**/*distributed_knowledge*.hpp'
- 'tests/**/*distributed_knowledge*.hxx'
- 'benchmarks/distributed_knowledge/**/*.c'
- 'benchmarks/distributed_knowledge/**/*.cc'
- 'benchmarks/distributed_knowledge/**/*.cpp'
- 'benchmarks/distributed_knowledge/**/*.cxx'
- 'benchmarks/distributed_knowledge/**/*.h'
- 'benchmarks/distributed_knowledge/**/*.hh'
- 'benchmarks/distributed_knowledge/**/*.hpp'
- 'benchmarks/distributed_knowledge/**/*.hxx'
- 'CMakeLists.txt'
- 'CMakePresets.json'
- 'cmake/**/*.cmake'
- 'cmake/**/*.txt'
- 'cmake/**/*.in'
- '.github/workflows/gate-distributed-knowledge.yml'
pull_request:
branches:
- develop
paths:
- 'src/distributed_knowledge/**/*.c'
- 'src/distributed_knowledge/**/*.cc'
- 'src/distributed_knowledge/**/*.cpp'
- 'src/distributed_knowledge/**/*.cxx'
- 'src/distributed_knowledge/**/*.h'
- 'src/distributed_knowledge/**/*.hh'
- 'src/distributed_knowledge/**/*.hpp'
- 'src/distributed_knowledge/**/*.hxx'
- 'include/distributed_knowledge/**/*.h'
- 'include/distributed_knowledge/**/*.hh'
- 'include/distributed_knowledge/**/*.hpp'
- 'include/distributed_knowledge/**/*.hxx'
- 'tests/**/*distributed_knowledge*.c'
- 'tests/**/*distributed_knowledge*.cc'
- 'tests/**/*distributed_knowledge*.cpp'
- 'tests/**/*distributed_knowledge*.cxx'
- 'tests/**/*distributed_knowledge*.h'
- 'tests/**/*distributed_knowledge*.hh'
- 'tests/**/*distributed_knowledge*.hpp'
- 'tests/**/*distributed_knowledge*.hxx'
- 'benchmarks/distributed_knowledge/**/*.c'
- 'benchmarks/distributed_knowledge/**/*.cc'
- 'benchmarks/distributed_knowledge/**/*.cpp'
- 'benchmarks/distributed_knowledge/**/*.cxx'
- 'benchmarks/distributed_knowledge/**/*.h'
- 'benchmarks/distributed_knowledge/**/*.hh'
- 'benchmarks/distributed_knowledge/**/*.hpp'
- 'benchmarks/distributed_knowledge/**/*.hxx'
- 'CMakeLists.txt'
- 'CMakePresets.json'
- 'cmake/**/*.cmake'
- 'cmake/**/*.txt'
- 'cmake/**/*.in'
- '.github/workflows/gate-distributed-knowledge.yml'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-gate-distributed-knowledge-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-distributed-knowledge:
name: Build Producer (distributed_knowledge)
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
actions: read
env:
SCCACHE_GHA_ENABLED: "false"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup C++ build dependencies
uses: ./.github/actions/setup-cpp-build
with:
cc: gcc-12
cxx: g++-12
extra-packages: librocksdb-dev libssl-dev zlib1g-dev libspdlog-dev nlohmann-json3-dev libtbb-dev libyaml-cpp-dev libmimalloc-dev libcurl4-openssl-dev libboost-system-dev libbenchmark-dev libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc libpugixml-dev
- name: Configure (community-release)
run: |
set -euo pipefail
cmake --preset community-release -DTHEMIS_BUILD_TESTS=ON -DTHEMIS_BUILD_BENCHMARKS=ON
- name: Build focused validation targets once
run: |
set -euo pipefail
cmake --build build-community-release \
--target module_distributed_knowledge_test_dk_contract_hardening_focused \
--target module_distributed_knowledge_test_adapter_capability_announcement_focused \
--target bench_dk_release_gates \
--parallel "$(nproc)"
- name: Upload build tree for consumer jobs
uses: actions/upload-artifact@v4
with:
name: dk-build-tree-${{ github.run_number }}
path: build-community-release/
retention-days: 7
if-no-files-found: error
validate-unit-tests:
name: Unit Tests Consumer
runs-on: ubuntu-latest
timeout-minutes: 20
needs: build-distributed-knowledge
steps:
- name: Setup C++ runtime dependencies
uses: ./.github/actions/setup-cpp-build
with:
cc: gcc-12
cxx: g++-12
extra-packages: librocksdb-dev libssl-dev zlib1g-dev libspdlog-dev nlohmann-json3-dev libtbb-dev libyaml-cpp-dev libmimalloc-dev libcurl4-openssl-dev libboost-system-dev libbenchmark-dev libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc libpugixml-dev
- name: Download build tree
uses: actions/download-artifact@v4
with:
name: dk-build-tree-${{ github.run_number }}
path: .
- name: Run module unit tests from producer artifact
run: |
set -euo pipefail
ctest --test-dir build-community-release \
-R module_distributed_knowledge_test \
--verbose \
--output-on-failure \
--timeout 300
validate-benchmarks:
name: Benchmark Consumer
runs-on: ubuntu-latest
timeout-minutes: 25
needs: build-distributed-knowledge
steps:
- name: Setup C++ runtime dependencies
uses: ./.github/actions/setup-cpp-build
with:
cc: gcc-12
cxx: g++-12
extra-packages: librocksdb-dev libssl-dev zlib1g-dev libspdlog-dev nlohmann-json3-dev libtbb-dev libyaml-cpp-dev libmimalloc-dev libcurl4-openssl-dev libboost-system-dev libbenchmark-dev libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc libpugixml-dev
- name: Download build tree
uses: actions/download-artifact@v4
with:
name: dk-build-tree-${{ github.run_number }}
path: .
- name: Run benchmark gate from producer artifact
run: |
set -euo pipefail
ctest --test-dir build-community-release \
-R bench_dk_release_gates \
--verbose \
--output-on-failure \
--timeout 600
verify-gap-closure:
name: Verify Gap Closure Pattern
needs: [validate-unit-tests, validate-benchmarks]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run gap scanner
run: |
cd /home/runner/work/ThemisDB/ThemisDB
SCAN_OUTPUT_DIR="/tmp/distributed-knowledge-gap-scan"
mkdir -p "${SCAN_OUTPUT_DIR}"
# Run the scanner and evaluate findings from its JSON output.
# gap_scanner.py currently exits non-zero when summary fields are empty,
# so we still validate against the produced module report.
python tools/gap_scanner.py \
--repo . \
--module distributed_knowledge \
--output "${SCAN_OUTPUT_DIR}" || true
SCAN_FILE="${SCAN_OUTPUT_DIR}/gap_scan_distributed_knowledge.json"
if [ ! -f "${SCAN_FILE}" ]; then
echo "Gap scanner output not found: ${SCAN_FILE}"
exit 1
fi
CURRENT_FINDINGS=$(python - << 'PY'
import json
with open("/tmp/distributed-knowledge-gap-scan/gap_scan_distributed_knowledge.json", "r", encoding="utf-8") as f:
report = json.load(f)
print(len(report.get("gaps", [])))
PY
)
BASELINE_FINDINGS=111
CLOSURE_RATE=$(python -c "baseline=${BASELINE_FINDINGS}; current=int(${CURRENT_FINDINGS}); print(round((1 - (current / baseline)) * 100, 2))")
PATTERN_CLOSURE=$(python -c "baseline=${BASELINE_FINDINGS}; current=int(${CURRENT_FINDINGS}); print(round((current / baseline) * 100, 2))")
echo "Running follow-up gap scan..."
echo "Current findings: ${CURRENT_FINDINGS}"
echo "Pattern closure: ${PATTERN_CLOSURE}%"
if python -c "import sys; sys.exit(0 if float(${PATTERN_CLOSURE}) < 20.0 else 1)"; then
echo "Gap closure threshold check passed (<20%)."
else
echo "Gap closure threshold check failed: ${PATTERN_CLOSURE}% >= 20%."
exit 1
fi
{
echo "### Gap Closure Verification"
echo ""
echo "**Original Scan (2026-06-04):** 111 findings"
echo "**Current Status:** ${CURRENT_FINDINGS} findings"
echo "**Closure Rate:** ${CLOSURE_RATE}%"
echo "**Pattern Closure:** ${PATTERN_CLOSURE}% < 20% ✅"
} >> "$GITHUB_STEP_SUMMARY"