Skip to content

Port Go search snapshot tests into C++ - #129

Merged
usrname1git merged 1 commit into
mainfrom
feat/cpp-search-snapshot-tests
Sep 10, 2026
Merged

Port Go search snapshot tests into C++#129
usrname1git merged 1 commit into
mainfrom
feat/cpp-search-snapshot-tests

Conversation

@usrname1git

Copy link
Copy Markdown
Owner

Goal

Port the Go http_test.go searchConsistently cases into C++ so the fail-closed snapshot gate is asserted offline (the leftover from #128).

What

  • SearchHealthSnap + search_before_gate / search_after_gate / same_search_snapshot in cpp_memory_store core (no Mongo).
  • rag-service search uses those gates. Hybrid responses bind embedding identity the same way Go validResponseCapability does.
  • run_snapshot_self_test covers: stable snapshot, partial interleave (no result leak, no second search), retry-fresh, rebuild bound (2 attempts), unready first look, hybrid semantic-unavailable, hybrid identity match/mismatch.

Go memory_store/ stays rollback.

Verify

  • ctest --test-dir build/cpp_memory_store -C Release: protocol (now includes snapshot) + rag-eval self/offline pass
  • Live :8084 after bounce: health ready, search 8 hits citation_status=available

Lift before/after search gates out of rag-service so ctest can assert
stable snapshot, partial interleave, retry-fresh, rebuild bound, and
hybrid identity without Mongo.
Copilot AI lite review requested due to automatic review settings September 10, 2026 20:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new snapshot gate currently omits response field consistency checks (e.g., generation/projection_version parity with Go), weakening the intended fail-closed invariant being ported.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Ports the Go searchConsistently snapshot-gating behavior into the C++ cpp_memory_store so rag-service can fail closed when corpus/health changes mid-search, and so the gate can be asserted offline via a self-test.

Changes:

  • Adds SearchHealthSnap + search_before_gate / search_after_gate / same_search_snapshot helpers and an offline snapshot self-test.
  • Refactors rag-service search to reuse the shared snapshot gate helpers (including bounded retry attempts).
  • Updates the C++ memory store self-test runner and README “cut” notes to include the new snapshot self-test.
File summaries
File Description
godbrain_core/cpp_memory_store/tests/tests.cpp Runs the new snapshot self-test alongside the existing protocol self-test.
godbrain_core/cpp_memory_store/src/rag_snapshot.cpp Implements snapshot gating helpers and the offline snapshot self-test scenarios.
godbrain_core/cpp_memory_store/src/rag_engine.cpp Switches /v1/search gating to shared snapshot helpers and uses the shared retry bound.
godbrain_core/cpp_memory_store/include/godbrain/memory_store/snapshot.hpp Declares the snapshot gate API and shared retry constant.
godbrain_core/cpp_memory_store/CMakeLists.txt Adds the new snapshot implementation file to the core library build.
godbrain_core/cpp_memory_store/README.md Documents “Cut 13” and the new offline snapshot self-test coverage.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +123 to +136
return before.ready && after.ready && before.mongo == "ok" && after.mongo == "ok" &&
!before.active_generation.empty() && before.active_generation == after.active_generation &&
before.building_generation == after.building_generation && !before.projection_version.empty() &&
before.projection_version == after.projection_version &&
before.projection_schema == after.projection_schema && before.indexer_version == after.indexer_version &&
before.retrieval_mode == after.retrieval_mode && same_semantic(before, after) && same_counts(before, after) &&
same_optional_millis(
before.latest_committed, before.committed_at, after.latest_committed, after.committed_at) &&
same_optional_millis(
before.latest_projected, before.projected_at, after.latest_projected, after.projected_at) &&
same_optional_millis(
before.latest_embedded, before.embedded_at, after.latest_embedded, after.embedded_at) &&
valid_response_capability(before, retrieval, hybrid, degradation, response_embedding);
}
@usrname1git
usrname1git merged commit ec4fb66 into main Sep 10, 2026
1 check passed
@usrname1git
usrname1git deleted the feat/cpp-search-snapshot-tests branch September 10, 2026 20:41
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