LCOV - code coverage report
Current view: top level - include/esys/repo/sharing - inventory.h (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 1 1 100.0 %
Date: 2026-11-07 22:18:26 Functions: 0 0 -

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/sharing/inventory.h
       3             :  * \brief In-memory dependency inventory (ADR-0042)
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2026 Michel Gillet
       9             :  * Distributed under the MIT License.
      10             :  * (See accompanying file LICENSE.txt or
      11             :  * copy at https://opensource.org/licenses/MIT)
      12             :  *
      13             :  * __legal_e__
      14             :  * \endcond
      15             :  *
      16             :  */
      17             : 
      18             : #pragma once
      19             : 
      20             : #include "esys/repo/esysrepo_defs.h"
      21             : #include "esys/repo/sharing/occurrence.h"
      22             : 
      23             : #include <map>
      24             : #include <set>
      25             : #include <string>
      26             : #include <vector>
      27             : 
      28             : namespace esys::repo::sharing
      29             : {
      30             : 
      31             : enum class Coverage
      32             : {
      33             :     Unknown = 0,
      34             :     Partial, //!< Targeted sync / incomplete inspection
      35             :     Complete, //!< Full successful inspection of marked scopes
      36             : };
      37             : 
      38             : /*! \class Inventory esys/repo/sharing/inventory.h "esys/repo/sharing/inventory.h"
      39             :  * \brief Observations keyed by consumer+dependency path (tool-private model)
      40             :  */
      41             : class ESYSREPO_API Inventory
      42             : {
      43             : public:
      44          28 :     Inventory() = default;
      45             : 
      46             :     void clear();
      47             : 
      48             :     //! Insert or replace by ``Occurrence::scope_key()``
      49             :     void upsert(const Occurrence &occurrence);
      50             : 
      51             :     const std::vector<Occurrence> &get_occurrences() const;
      52             : 
      53             :     void set_coverage(Coverage coverage);
      54             :     Coverage get_coverage() const;
      55             : 
      56             :     //! Mark a consumer path as successfully reinspected (for drop-on-reinspect)
      57             :     void mark_scope_inspected(const std::string &consumer_path);
      58             : 
      59             :     //! Drop occurrences under ``consumer_path`` that were not upserted since mark
      60             :     void drop_stale_in_scope(const std::string &consumer_path);
      61             : 
      62             :     //! Group by normalized identity (empty identity skipped)
      63             :     std::map<std::string, std::vector<Occurrence>> group_by_identity() const;
      64             : 
      65             :     /*! Warn-candidates: identity with ≥2 occurrences and not in ``registered``.
      66             :      *  Registered shared identities are excluded (ADR-0042 §12).
      67             :      */
      68             :     std::map<std::string, std::vector<Occurrence>>
      69             :     unregistered_duplicates(const std::set<std::string> &registered_identities) const;
      70             : 
      71             : private:
      72             :     std::vector<Occurrence> m_occurrences;
      73             :     Coverage m_coverage = Coverage::Unknown;
      74             :     std::set<std::string> m_inspected_scopes;
      75             :     std::set<std::string> m_seen_keys_this_pass;
      76             : };
      77             : 
      78             : } // namespace esys::repo::sharing

Generated by: LCOV version 1.14