Skip to content

Make snapshots acyclic and align private namespaces - #8338

Open
Amaury Chamayou (achamayou) wants to merge 3 commits into
mainfrom
achamayou-component-dag
Open

Make snapshots acyclic and align private namespaces#8338
Amaury Chamayou (achamayou) wants to merge 3 commits into
mainfrom
achamayou-component-dag

Conversation

@achamayou

Copy link
Copy Markdown
Member

Summary

Make snapshots acyclic without changing any public headers.

  • Move TimeBoundLogger from host into ccf::ds, updating all consumers and preserving the shared configurable logging threshold.
  • Align the three private snapshot headers under ccf::snapshots and use the existing ccf::SeqNo for the writer's index parameters.
  • Enforce snapshots -> {ccf-api, ds, http, http_client}. Add standalone-header compilation coverage, logging regressions, and full-width snapshot-index coverage.

Snapshot formats and persistence behaviour are unchanged. No files under include/ccf are modified.

The measured source-component graph goes from 106 to 104 edges, 11 to 10 cyclic components, and 14 to 15 acyclic components, with 25 components overall.

Contributes to #3517; the full component DAG goal remains open.

Validation

Built with Clang 21.1.8 in WSL using the default RelWithDebInfo configuration. Validation used an LF export of the staged tree so Unix scripts could run without rewriting the Windows worktree.

  • Built js_generic, logging, curl_test, and the affected unit targets.
  • Passed logger_test, ledger_test, files_cleanup_test, indexing_test, and snapshotter_test.
  • Passed recovery_stale_snapshot_join_test, recovery_intermediate_snapshot_join_test, and recovery_snapshot_endorsements_test.
  • Passed the full scripts/ci-checks.sh; reran include and formatting checks after adding the explicit JSON prerequisite to the private fetch header.

Break the snapshots-to-host and snapshots-to-consensus dependencies without changing public headers.

Refs #3517.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 9, 2026 21:20
@achamayou
Amaury Chamayou (achamayou) requested a review from a team as a code owner September 9, 2026 21:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new TimeBoundLogger unit tests modify global logger/default state with manual restoration that is not exception-safe, risking cross-test contamination.

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

Pull request overview

This PR refactors internal snapshot and logging utilities to break include cycles and enforce a cleaner source-component dependency boundary, without modifying any public headers under include/ccf.

Changes:

  • Move TimeBoundLogger into ccf::ds and update host/snapshot consumers to use the new header/namespace.
  • Place private snapshot headers under ccf::snapshots, switch snapshot writer index parameters to ccf::SeqNo, and update call sites.
  • Add standalone-header compilation tests plus targeted regressions (time-bound logger behavior and full-width snapshot index handling), and enforce the new snapshots dependency policy.

Custom instructions used:

  • Instruction files loaded: none
  • Skill guidance applied: testing
File summaries
File Description
src/snapshots/test/snapshot_writer_header_test.cpp Standalone-include coverage for snapshots/snapshot_writer.h.
src/snapshots/test/filenames_header_test.cpp Standalone-include coverage for snapshots/filenames.h.
src/snapshots/test/fetch_header_test.cpp Standalone-include coverage for snapshots/fetch.h.
src/snapshots/snapshot_writer.h Move to ccf::snapshots, switch indices to ccf::SeqNo, and use ccf::ds::TimeBoundLogger.
src/snapshots/filenames.h Move to ccf::snapshots and switch to ccf::ds::TimeBoundLogger with explicit prerequisites.
src/snapshots/fetch.h Move to ccf::snapshots and add missing JSON prerequisite for standalone compilation.
src/node/test/snapshotter.cpp Update references to the new ccf::snapshots namespace.
src/host/test/ledger.cpp Add regression test for full-width snapshot sequence numbers; update namespace usage.
src/host/run.cpp Update include and configuration of TimeBoundLogger::default_max_time in ccf::ds.
src/host/lfs_file_handler.h Update include and use of ccf::ds::TimeBoundLogger.
src/host/ledger.h Update include and use of ccf::ds::TimeBoundLogger.
src/host/files_cleanup_timer.h Update include and snapshot namespace usage; use ccf::ds::TimeBoundLogger.
src/ds/time_bound_logger.h Move TimeBoundLogger into namespace ccf::ds.
src/ds/test/time_bound_logger_header_test.cpp Standalone-include coverage for ds/time_bound_logger.h.
src/ds/test/logger.cpp Add unit coverage for TimeBoundLogger formatting/default capture/log-level behavior.
scripts/source-dependencies.json Enforce snapshots -> {ccf-api, ds, http, http_client} dependency boundary.
CMakeLists.txt Wire new header tests and regressions into existing unit test targets.
Review details

Suppressed comments (1)

src/ds/test/logger.cpp:107

  • This test swaps out the global logger configuration/level and restores them manually; if any call between the exchange and the restore throws (eg allocation in make_unique/emplace_back), subsequent tests may run with the wrong logger state. Use an RAII guard to restore the previous configuration on all exit paths.
  ccf::logger::config::loggers() = std::move(previous_loggers);
  ccf::logger::config::level() = previous_level;
  • Files reviewed: 17/17 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/ds/test/logger.cpp Outdated
Guard global logger sinks, log level, and timing defaults in the new tests.
Cover restoration when an exception unwinds the guarded scope.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a3c18286-7019-45e6-bd42-2f9ef7e10c48
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