clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version.  The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.

See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.

Change-Id: Ic68b91e23738cafe198c50f40e46d4163bda02b6
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
 IndentWrappedFunctionNames: true
 InsertNewlineAtEOF: true
 KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
 LineEnding: LF
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
@@ -98,13 +98,14 @@
 ObjCSpaceBeforeProtocolList: true
 PackConstructorInitializers: BinPack
 PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
 PenaltyBreakComment: 300
 PenaltyBreakFirstLessLess: 120
 PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
 PointerAlignment: Left
 QualifierAlignment: Left
 ReferenceAlignment: Left
diff --git a/fail-monitor/monitor.cpp b/fail-monitor/monitor.cpp
index 2c3b31d..2c4beb7 100644
--- a/fail-monitor/monitor.cpp
+++ b/fail-monitor/monitor.cpp
@@ -93,8 +93,8 @@
 void Monitor::runTargetAction()
 {
     // Start or stop the target unit
-    const auto* methodCall = (action == Action::start) ? startMethod
-                                                       : stopMethod;
+    const auto* methodCall =
+        (action == Action::start) ? startMethod : stopMethod;
 
     log<level::INFO>("The source unit is in failed state, "
                      "running target action",
diff --git a/fail-monitor/monitor.hpp b/fail-monitor/monitor.hpp
index 9c98fdf..65bb810 100644
--- a/fail-monitor/monitor.hpp
+++ b/fail-monitor/monitor.hpp
@@ -49,8 +49,8 @@
      */
     Monitor(const std::string& sourceUnit, const std::string& targetUnit,
             Action action) :
-        bus(sdbusplus::bus::new_default()),
-        source(sourceUnit), target(targetUnit), action(action)
+        bus(sdbusplus::bus::new_default()), source(sourceUnit),
+        target(targetUnit), action(action)
     {}
 
     /**
diff --git a/src/associations.cpp b/src/associations.cpp
index 927eec1..1899826 100644
--- a/src/associations.cpp
+++ b/src/associations.cpp
@@ -39,10 +39,9 @@
     }
 }
 
-void scheduleUpdateEndpointsOnDbus(boost::asio::io_context& io,
-                                   sdbusplus::asio::object_server& objectServer,
-                                   const std::string& assocPath,
-                                   AssociationMaps& assocMaps)
+void scheduleUpdateEndpointsOnDbus(
+    boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer,
+    const std::string& assocPath, AssociationMaps& assocMaps)
 {
     static std::set<std::string> delayedUpdatePaths;
 
@@ -192,8 +191,8 @@
             for (const auto& originalEndpoint : originalEndpoints)
             {
                 if (std::find(newEndpoints->second.begin(),
-                              newEndpoints->second.end(),
-                              originalEndpoint) == newEndpoints->second.end())
+                              newEndpoints->second.end(), originalEndpoint) ==
+                    newEndpoints->second.end())
                 {
                     toRemove.emplace(originalEndpoint);
                 }
@@ -227,12 +226,11 @@
     scheduleUpdateEndpointsOnDbus(io, objectServer, assocPath, assocMaps);
 }
 
-void associationChanged(boost::asio::io_context& io,
-                        sdbusplus::asio::object_server& objectServer,
-                        const std::vector<Association>& associations,
-                        const std::string& path, const std::string& owner,
-                        const InterfaceMapType& interfaceMap,
-                        AssociationMaps& assocMaps)
+void associationChanged(
+    boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer,
+    const std::vector<Association>& associations, const std::string& path,
+    const std::string& owner, const InterfaceMapType& interfaceMap,
+    AssociationMaps& assocMaps)
 {
     AssociationPaths objects;
 
@@ -301,11 +299,10 @@
     }
 }
 
-void addPendingAssociation(const std::string& objectPath,
-                           const std::string& type,
-                           const std::string& endpointPath,
-                           const std::string& endpointType,
-                           const std::string& owner, AssociationMaps& assocMaps)
+void addPendingAssociation(
+    const std::string& objectPath, const std::string& type,
+    const std::string& endpointPath, const std::string& endpointType,
+    const std::string& owner, AssociationMaps& assocMaps)
 {
     Association assoc{type, endpointType, endpointPath};
 
@@ -321,11 +318,12 @@
         // Already waiting on this path for another association,
         // so just add this endpoint and owner.
         auto& endpoints = p->second;
-        auto e = std::find_if(endpoints.begin(), endpoints.end(),
-                              [&assoc, &owner](const auto& endpoint) {
-            return (std::get<ownerPos>(endpoint) == owner) &&
-                   (std::get<assocPos>(endpoint) == assoc);
-        });
+        auto e =
+            std::find_if(endpoints.begin(), endpoints.end(),
+                         [&assoc, &owner](const auto& endpoint) {
+                             return (std::get<ownerPos>(endpoint) == owner) &&
+                                    (std::get<assocPos>(endpoint) == assoc);
+                         });
         if (e == endpoints.end())
         {
             endpoints.emplace_back(owner, std::move(assoc));
@@ -362,12 +360,11 @@
     }
 }
 
-void addSingleAssociation(boost::asio::io_context& io,
-                          sdbusplus::asio::object_server& server,
-                          const std::string& assocPath,
-                          const std::string& endpoint, const std::string& owner,
-                          const std::string& ownerPath,
-                          AssociationMaps& assocMaps)
+void addSingleAssociation(
+    boost::asio::io_context& io, sdbusplus::asio::object_server& server,
+    const std::string& assocPath, const std::string& endpoint,
+    const std::string& owner, const std::string& ownerPath,
+    AssociationMaps& assocMaps)
 {
     boost::container::flat_set<std::string> endpoints{endpoint};
 
@@ -406,11 +403,10 @@
     }
 }
 
-void checkIfPendingAssociation(boost::asio::io_context& io,
-                               const std::string& objectPath,
-                               const InterfaceMapType& interfaceMap,
-                               AssociationMaps& assocMaps,
-                               sdbusplus::asio::object_server& server)
+void checkIfPendingAssociation(
+    boost::asio::io_context& io, const std::string& objectPath,
+    const InterfaceMapType& interfaceMap, AssociationMaps& assocMaps,
+    sdbusplus::asio::object_server& server)
 {
     auto pending = assocMaps.pending.find(objectPath);
     if (pending == assocMaps.pending.end())
@@ -508,15 +504,15 @@
                     auto a = std::find_if(
                         assocs.begin(), assocs.end(),
                         [&endpointPath, &otherPath](const auto& ap) {
-                        const auto& endpoints = ap.second;
-                        auto endpoint = std::find(endpoints.begin(),
-                                                  endpoints.end(), otherPath);
-                        if (endpoint != endpoints.end())
-                        {
-                            return ap.first.starts_with(endpointPath + '/');
-                        }
-                        return false;
-                    });
+                            const auto& endpoints = ap.second;
+                            auto endpoint = std::find(
+                                endpoints.begin(), endpoints.end(), otherPath);
+                            if (endpoint != endpoints.end())
+                            {
+                                return ap.first.starts_with(endpointPath + '/');
+                            }
+                            return false;
+                        });
 
                     if (a != assocs.end())
                     {
@@ -545,11 +541,10 @@
  * @param[in,out] assocMaps - the association maps
  * @param[in,out] server    - sdbus system object
  */
-void removeAssociationIfacesEntry(boost::asio::io_context& io,
-                                  const std::string& assocPath,
-                                  const std::string& endpointPath,
-                                  AssociationMaps& assocMaps,
-                                  sdbusplus::asio::object_server& server)
+void removeAssociationIfacesEntry(
+    boost::asio::io_context& io, const std::string& assocPath,
+    const std::string& endpointPath, AssociationMaps& assocMaps,
+    sdbusplus::asio::object_server& server)
 {
     auto assoc = assocMaps.ifaces.find(assocPath);
     if (assoc != assocMaps.ifaces.end())
@@ -576,10 +571,9 @@
  * @param[in] owner         - the owner of the association
  * @param[in,out] assocMaps - the association maps
  */
-void removeAssociationOwnersEntry(const std::string& assocPath,
-                                  const std::string& endpointPath,
-                                  const std::string& owner,
-                                  AssociationMaps& assocMaps)
+void removeAssociationOwnersEntry(
+    const std::string& assocPath, const std::string& endpointPath,
+    const std::string& owner, AssociationMaps& assocMaps)
 {
     auto sources = assocMaps.owners.begin();
     while (sources != assocMaps.owners.end())
@@ -617,10 +611,9 @@
     }
 }
 
-void moveAssociationToPending(boost::asio::io_context& io,
-                              const std::string& endpointPath,
-                              AssociationMaps& assocMaps,
-                              sdbusplus::asio::object_server& server)
+void moveAssociationToPending(
+    boost::asio::io_context& io, const std::string& endpointPath,
+    AssociationMaps& assocMaps, sdbusplus::asio::object_server& server)
 {
     FindAssocResults associationData;
 
diff --git a/src/associations.hpp b/src/associations.hpp
index 1d7b778..1ea5c2d 100644
--- a/src/associations.hpp
+++ b/src/associations.hpp
@@ -87,12 +87,11 @@
  *
  * @return Void, objectServer and assocMaps updated if needed
  */
-void associationChanged(boost::asio::io_context& io,
-                        sdbusplus::asio::object_server& objectServer,
-                        const std::vector<Association>& associations,
-                        const std::string& path, const std::string& owner,
-                        const InterfaceMapType& interfaceMap,
-                        AssociationMaps& assocMaps);
+void associationChanged(
+    boost::asio::io_context& io, sdbusplus::asio::object_server& objectServer,
+    const std::vector<Association>& associations, const std::string& path,
+    const std::string& owner, const InterfaceMapType& interfaceMap,
+    AssociationMaps& assocMaps);
 
 /** @brief Add a pending associations entry
  *
@@ -114,12 +113,10 @@
  * @param[in] owner         - The service name that owns the association.
  * @param[in,out] assocMaps - The association maps
  */
-void addPendingAssociation(const std::string& objectPath,
-                           const std::string& type,
-                           const std::string& endpointPath,
-                           const std::string& endpointType,
-                           const std::string& owner,
-                           AssociationMaps& assocMaps);
+void addPendingAssociation(
+    const std::string& objectPath, const std::string& type,
+    const std::string& endpointPath, const std::string& endpointType,
+    const std::string& owner, AssociationMaps& assocMaps);
 
 /** @brief Removes an endpoint from the pending associations map
  *
@@ -141,12 +138,11 @@
  * @param[in] ownerPath     - The D-Bus path hosting the Associations property
  * @param[in,out] assocMaps - The association maps
  */
-void addSingleAssociation(boost::asio::io_context& io,
-                          sdbusplus::asio::object_server& server,
-                          const std::string& assocPath,
-                          const std::string& endpoint, const std::string& owner,
-                          const std::string& ownerPath,
-                          AssociationMaps& assocMaps);
+void addSingleAssociation(
+    boost::asio::io_context& io, sdbusplus::asio::object_server& server,
+    const std::string& assocPath, const std::string& endpoint,
+    const std::string& owner, const std::string& ownerPath,
+    AssociationMaps& assocMaps);
 
 /** @brief Create a real association out of a pending association
  *         if there is one for this path.
@@ -161,11 +157,10 @@
  * @param[in,out] assocMaps - The association maps
  * @param[in,out] server    - sdbus system object
  */
-void checkIfPendingAssociation(boost::asio::io_context& io,
-                               const std::string& objectPath,
-                               const InterfaceMapType& interfaceMap,
-                               AssociationMaps& assocMaps,
-                               sdbusplus::asio::object_server& server);
+void checkIfPendingAssociation(
+    boost::asio::io_context& io, const std::string& objectPath,
+    const InterfaceMapType& interfaceMap, AssociationMaps& assocMaps,
+    sdbusplus::asio::object_server& server);
 
 /** @brief Find all associations in the association owners map with the
  *         specified endpoint path.
@@ -191,7 +186,6 @@
  * @param[in,out] assocMaps - The association maps
  * @param[in,out] server    - sdbus system object
  */
-void moveAssociationToPending(boost::asio::io_context& io,
-                              const std::string& endpointPath,
-                              AssociationMaps& assocMaps,
-                              sdbusplus::asio::object_server& server);
+void moveAssociationToPending(
+    boost::asio::io_context& io, const std::string& endpointPath,
+    AssociationMaps& assocMaps, sdbusplus::asio::object_server& server);
diff --git a/src/handler.cpp b/src/handler.cpp
index 67dc541..30b7ba3 100644
--- a/src/handler.cpp
+++ b/src/handler.cpp
@@ -77,11 +77,11 @@
                         interfaces.size(), interfaceMap.second.size()));
                     // Return iterator points at the first output elemtn,
                     // meaning that there are no intersections.
-                    if (std::set_intersection(interfaces.begin(),
-                                              interfaces.end(),
-                                              interfaceMap.second.begin(),
-                                              interfaceMap.second.end(),
-                                              output.begin()) != output.begin())
+                    if (std::set_intersection(
+                            interfaces.begin(), interfaces.end(),
+                            interfaceMap.second.begin(),
+                            interfaceMap.second.end(), output.begin()) !=
+                        output.begin())
                     {
                         addObjectMapResult(ret, thisPath, interfaceMap);
                     }
@@ -119,8 +119,8 @@
         // meaning that there are no intersections.
         if (std::set_intersection(interfaces.begin(), interfaces.end(),
                                   interfaceMap.second.begin(),
-                                  interfaceMap.second.end(),
-                                  output.begin()) != output.begin())
+                                  interfaceMap.second.end(), output.begin()) !=
+            output.begin())
         {
             results.emplace(interfaceMap.first, interfaceMap.second);
         }
@@ -203,9 +203,9 @@
     return ret;
 }
 
-std::vector<std::string> getSubTreePaths(const InterfaceMapType& interfaceMap,
-                                         std::string reqPath, int32_t depth,
-                                         std::vector<std::string>& interfaces)
+std::vector<std::string>
+    getSubTreePaths(const InterfaceMapType& interfaceMap, std::string reqPath,
+                    int32_t depth, std::vector<std::string>& interfaces)
 {
     if (depth <= 0)
     {
@@ -255,11 +255,11 @@
                         interfaces.size(), interfaceMap.second.size()));
                     // Return iterator points at the first output elemtn,
                     // meaning that there are no intersections.
-                    if (std::set_intersection(interfaces.begin(),
-                                              interfaces.end(),
-                                              interfaceMap.second.begin(),
-                                              interfaceMap.second.end(),
-                                              output.begin()) != output.begin())
+                    if (std::set_intersection(
+                            interfaces.begin(), interfaces.end(),
+                            interfaceMap.second.begin(),
+                            interfaceMap.second.end(), output.begin()) !=
+                        output.begin())
                     {
                         add = true;
                         break;
@@ -277,12 +277,12 @@
     return ret;
 }
 
-std::vector<InterfaceMapType::value_type>
-    getAssociatedSubTree(const InterfaceMapType& interfaceMap,
-                         const AssociationMaps& associationMaps,
-                         const sdbusplus::message::object_path& associationPath,
-                         const sdbusplus::message::object_path& reqPath,
-                         int32_t depth, std::vector<std::string>& interfaces)
+std::vector<InterfaceMapType::value_type> getAssociatedSubTree(
+    const InterfaceMapType& interfaceMap,
+    const AssociationMaps& associationMaps,
+    const sdbusplus::message::object_path& associationPath,
+    const sdbusplus::message::object_path& reqPath, int32_t depth,
+    std::vector<std::string>& interfaces)
 {
     auto findEndpoint = associationMaps.ifaces.find(associationPath.str);
     if (findEndpoint == associationMaps.ifaces.end())
diff --git a/src/handler.hpp b/src/handler.hpp
index 9e692e5..515c937 100644
--- a/src/handler.hpp
+++ b/src/handler.hpp
@@ -21,9 +21,9 @@
     getSubTree(const InterfaceMapType& interfaceMap, std::string reqPath,
                int32_t depth, std::vector<std::string>& interfaces);
 
-std::vector<std::string> getSubTreePaths(const InterfaceMapType& interfaceMap,
-                                         std::string reqPath, int32_t depth,
-                                         std::vector<std::string>& interfaces);
+std::vector<std::string>
+    getSubTreePaths(const InterfaceMapType& interfaceMap, std::string reqPath,
+                    int32_t depth, std::vector<std::string>& interfaces);
 
 /**
  * @brief Get the Associated Sub Tree object
@@ -40,12 +40,12 @@
  *
  * @return std::vector<InterfaceMapType::value_type>
  */
-std::vector<InterfaceMapType::value_type>
-    getAssociatedSubTree(const InterfaceMapType& interfaceMap,
-                         const AssociationMaps& associationMaps,
-                         const sdbusplus::message::object_path& associationPath,
-                         const sdbusplus::message::object_path& reqPath,
-                         int32_t depth, std::vector<std::string>& interfaces);
+std::vector<InterfaceMapType::value_type> getAssociatedSubTree(
+    const InterfaceMapType& interfaceMap,
+    const AssociationMaps& associationMaps,
+    const sdbusplus::message::object_path& associationPath,
+    const sdbusplus::message::object_path& reqPath, int32_t depth,
+    std::vector<std::string>& interfaces);
 
 /**
  * @brief Get the Associated Sub Tree Paths object
diff --git a/src/main.cpp b/src/main.cpp
index 85f0a92..694acd1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -34,14 +34,14 @@
     conn->async_method_call(
         [&, newObject](const boost::system::error_code ec,
                        const std::string& nameOwner) {
-        if (ec)
-        {
-            std::cerr << "Error getting owner of " << newObject << " : " << ec
-                      << "\n";
-            return;
-        }
-        owners[nameOwner] = newObject;
-    },
+            if (ec)
+            {
+                std::cerr << "Error getting owner of " << newObject << " : "
+                          << ec << "\n";
+                return;
+            }
+            owners[nameOwner] = newObject;
+        },
         "org.freedesktop.DBus", "/", "org.freedesktop.DBus", "GetNameOwner",
         newObject);
 }
@@ -75,8 +75,7 @@
             globalStartTime
 #endif
         ) :
-        systemBus(systemBus),
-        io(io), processName(processName), assocMaps(am)
+        systemBus(systemBus), io(io), processName(processName), assocMaps(am)
 #ifdef MAPPER_ENABLE_DEBUG
         ,
         globalStartTime(std::move(globalStartTime)),
@@ -142,22 +141,22 @@
          timeoutRetries](
             const boost::system::error_code ec,
             const std::variant<std::vector<Association>>& variantAssociations) {
-        if (ec)
-        {
-            if (ec.value() == boost::system::errc::timed_out &&
-                timeoutRetries < maxTimeoutRetries)
+            if (ec)
             {
-                doAssociations(io, systemBus, interfaceMap, objectServer,
-                               processName, path, timeoutRetries + 1);
-                return;
+                if (ec.value() == boost::system::errc::timed_out &&
+                    timeoutRetries < maxTimeoutRetries)
+                {
+                    doAssociations(io, systemBus, interfaceMap, objectServer,
+                                   processName, path, timeoutRetries + 1);
+                    return;
+                }
+                std::cerr << "Error getting associations from " << path << "\n";
             }
-            std::cerr << "Error getting associations from " << path << "\n";
-        }
-        std::vector<Association> associations =
-            std::get<std::vector<Association>>(variantAssociations);
-        associationChanged(io, objectServer, associations, path, processName,
-                           interfaceMap, associationMaps);
-    },
+            std::vector<Association> associations =
+                std::get<std::vector<Association>>(variantAssociations);
+            associationChanged(io, objectServer, associations, path,
+                               processName, interfaceMap, associationMaps);
+        },
         processName, path, "org.freedesktop.DBus.Properties", "Get",
         assocDefsInterface, assocDefsProperty);
 }
@@ -174,81 +173,82 @@
         [&io, &interfaceMap, &objectServer, transaction, path, systemBus,
          timeoutRetries](const boost::system::error_code ec,
                          const std::string& introspectXml) {
-        if (ec)
-        {
-            if (ec.value() == boost::system::errc::timed_out &&
-                timeoutRetries < maxTimeoutRetries)
+            if (ec)
             {
-                doIntrospect(io, systemBus, transaction, interfaceMap,
-                             objectServer, path, timeoutRetries + 1);
+                if (ec.value() == boost::system::errc::timed_out &&
+                    timeoutRetries < maxTimeoutRetries)
+                {
+                    doIntrospect(io, systemBus, transaction, interfaceMap,
+                                 objectServer, path, timeoutRetries + 1);
+                    return;
+                }
+                std::cerr << "Introspect call failed with error: " << ec << ", "
+                          << ec.message()
+                          << " on process: " << transaction->processName
+                          << " path: " << path << "\n";
                 return;
             }
-            std::cerr << "Introspect call failed with error: " << ec << ", "
-                      << ec.message()
-                      << " on process: " << transaction->processName
-                      << " path: " << path << "\n";
-            return;
-        }
 
-        tinyxml2::XMLDocument doc;
+            tinyxml2::XMLDocument doc;
 
-        tinyxml2::XMLError e = doc.Parse(introspectXml.c_str());
-        if (e != tinyxml2::XMLError::XML_SUCCESS)
-        {
-            std::cerr << "XML parsing failed\n";
-            return;
-        }
-
-        tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
-        if (pRoot == nullptr)
-        {
-            std::cerr << "XML document did not contain any data\n";
-            return;
-        }
-        auto& thisPathMap = interfaceMap[path];
-        tinyxml2::XMLElement* pElement = pRoot->FirstChildElement("interface");
-        while (pElement != nullptr)
-        {
-            const char* ifaceName = pElement->Attribute("name");
-            if (ifaceName == nullptr)
+            tinyxml2::XMLError e = doc.Parse(introspectXml.c_str());
+            if (e != tinyxml2::XMLError::XML_SUCCESS)
             {
-                continue;
+                std::cerr << "XML parsing failed\n";
+                return;
             }
 
-            thisPathMap[transaction->processName].emplace(ifaceName);
-
-            if (std::strcmp(ifaceName, assocDefsInterface) == 0)
+            tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
+            if (pRoot == nullptr)
             {
-                doAssociations(io, systemBus, interfaceMap, objectServer,
-                               transaction->processName, path);
+                std::cerr << "XML document did not contain any data\n";
+                return;
             }
-
-            pElement = pElement->NextSiblingElement("interface");
-        }
-
-        // Check if this new path has a pending association that can
-        // now be completed.
-        checkIfPendingAssociation(io, path, interfaceMap,
-                                  transaction->assocMaps, objectServer);
-
-        pElement = pRoot->FirstChildElement("node");
-        while (pElement != nullptr)
-        {
-            const char* childPath = pElement->Attribute("name");
-            if (childPath != nullptr)
+            auto& thisPathMap = interfaceMap[path];
+            tinyxml2::XMLElement* pElement =
+                pRoot->FirstChildElement("interface");
+            while (pElement != nullptr)
             {
-                std::string parentPath(path);
-                if (parentPath == "/")
+                const char* ifaceName = pElement->Attribute("name");
+                if (ifaceName == nullptr)
                 {
-                    parentPath.clear();
+                    continue;
                 }
 
-                doIntrospect(io, systemBus, transaction, interfaceMap,
-                             objectServer, parentPath + "/" + childPath);
+                thisPathMap[transaction->processName].emplace(ifaceName);
+
+                if (std::strcmp(ifaceName, assocDefsInterface) == 0)
+                {
+                    doAssociations(io, systemBus, interfaceMap, objectServer,
+                                   transaction->processName, path);
+                }
+
+                pElement = pElement->NextSiblingElement("interface");
             }
-            pElement = pElement->NextSiblingElement("node");
-        }
-    },
+
+            // Check if this new path has a pending association that can
+            // now be completed.
+            checkIfPendingAssociation(io, path, interfaceMap,
+                                      transaction->assocMaps, objectServer);
+
+            pElement = pRoot->FirstChildElement("node");
+            while (pElement != nullptr)
+            {
+                const char* childPath = pElement->Attribute("name");
+                if (childPath != nullptr)
+                {
+                    std::string parentPath(path);
+                    if (parentPath == "/")
+                    {
+                        parentPath.clear();
+                    }
+
+                    doIntrospect(io, systemBus, transaction, interfaceMap,
+                                 objectServer, parentPath + "/" + childPath);
+                }
+                pElement = pElement->NextSiblingElement("node");
+            }
+        },
         transaction->processName, path, "org.freedesktop.DBus.Introspectable",
         "Introspect");
 }
@@ -266,11 +266,11 @@
     if (needToIntrospect(processName))
     {
         std::shared_ptr<InProgressIntrospect> transaction =
-            std::make_shared<InProgressIntrospect>(systemBus, io, processName,
-                                                   assocMaps
+            std::make_shared<InProgressIntrospect>(
+                systemBus, io, processName, assocMaps
 #ifdef MAPPER_ENABLE_DEBUG
-                                                   ,
-                                                   globalStartTime
+                ,
+                globalStartTime
 #endif
             );
 
@@ -289,34 +289,34 @@
         [&io, &interfaceMap, &nameOwners, &objectServer, systemBus,
          &assocMaps](const boost::system::error_code ec,
                      std::vector<std::string> processNames) {
-        if (ec)
-        {
-            std::cerr << "Error getting names: " << ec << "\n";
-            std::exit(EXIT_FAILURE);
-            return;
-        }
-        // Try to make startup consistent
-        std::sort(processNames.begin(), processNames.end());
-#ifdef MAPPER_ENABLE_DEBUG
-        std::shared_ptr<std::chrono::time_point<std::chrono::steady_clock>>
-            globalStartTime = std::make_shared<
-                std::chrono::time_point<std::chrono::steady_clock>>(
-                std::chrono::steady_clock::now());
-#endif
-        for (const std::string& processName : processNames)
-        {
-            if (needToIntrospect(processName))
+            if (ec)
             {
-                startNewIntrospect(systemBus, io, interfaceMap, processName,
-                                   assocMaps,
-#ifdef MAPPER_ENABLE_DEBUG
-                                   globalStartTime,
-#endif
-                                   objectServer);
-                updateOwners(systemBus, nameOwners, processName);
+                std::cerr << "Error getting names: " << ec << "\n";
+                std::exit(EXIT_FAILURE);
+                return;
             }
-        }
-    },
+            // Try to make startup consistent
+            std::sort(processNames.begin(), processNames.end());
+#ifdef MAPPER_ENABLE_DEBUG
+            std::shared_ptr<std::chrono::time_point<std::chrono::steady_clock>>
+                globalStartTime = std::make_shared<
+                    std::chrono::time_point<std::chrono::steady_clock>>(
+                    std::chrono::steady_clock::now());
+#endif
+            for (const std::string& processName : processNames)
+            {
+                if (needToIntrospect(processName))
+                {
+                    startNewIntrospect(systemBus, io, interfaceMap, processName,
+                                       assocMaps,
+#ifdef MAPPER_ENABLE_DEBUG
+                                       globalStartTime,
+#endif
+                                       objectServer);
+                    updateOwners(systemBus, nameOwners, processName);
+                }
+            }
+        },
         "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus",
         "ListNames");
 }
@@ -361,11 +361,12 @@
         auto childPath = parent + '/';
 
         // Remove this parent if there isn't a remaining child on this owner
-        auto child = std::find_if(interfaceMap.begin(), interfaceMap.end(),
-                                  [&owner, &childPath](const auto& entry) {
-            return entry.first.starts_with(childPath) &&
-                   (entry.second.find(owner) != entry.second.end());
-        });
+        auto child = std::find_if(
+            interfaceMap.begin(), interfaceMap.end(),
+            [&owner, &childPath](const auto& entry) {
+                return entry.first.starts_with(childPath) &&
+                       (entry.second.find(owner) != entry.second.end());
+            });
 
         if (child == interfaceMap.end())
         {
@@ -392,8 +393,9 @@
 
     // Construct a signal set registered for process termination.
     boost::asio::signal_set signals(io, SIGINT, SIGTERM);
-    signals.async_wait(
-        [&io](const boost::system::error_code&, int) { io.stop(); });
+    signals.async_wait([&io](const boost::system::error_code&, int) {
+        io.stop();
+    });
 
     InterfaceMapType interfaceMap;
     boost::container::flat_map<std::string, std::string> nameOwners;
@@ -572,47 +574,47 @@
     iface->register_method(
         "GetAncestors", [&interfaceMap](std::string& reqPath,
                                         std::vector<std::string>& interfaces) {
-        return getAncestors(interfaceMap, reqPath, interfaces);
-    });
+            return getAncestors(interfaceMap, reqPath, interfaces);
+        });
 
     iface->register_method(
         "GetObject", [&interfaceMap](const std::string& path,
                                      std::vector<std::string>& interfaces) {
-        return getObject(interfaceMap, path, interfaces);
-    });
+            return getObject(interfaceMap, path, interfaces);
+        });
 
     iface->register_method(
         "GetSubTree", [&interfaceMap](std::string& reqPath, int32_t depth,
                                       std::vector<std::string>& interfaces) {
-        return getSubTree(interfaceMap, reqPath, depth, interfaces);
-    });
+            return getSubTree(interfaceMap, reqPath, depth, interfaces);
+        });
 
     iface->register_method(
         "GetSubTreePaths",
         [&interfaceMap](std::string& reqPath, int32_t depth,
                         std::vector<std::string>& interfaces) {
-        return getSubTreePaths(interfaceMap, reqPath, depth, interfaces);
-    });
+            return getSubTreePaths(interfaceMap, reqPath, depth, interfaces);
+        });
 
     iface->register_method(
         "GetAssociatedSubTree",
         [&interfaceMap](const sdbusplus::message::object_path& associationPath,
                         const sdbusplus::message::object_path& reqPath,
                         int32_t depth, std::vector<std::string>& interfaces) {
-        return getAssociatedSubTree(interfaceMap, associationMaps,
-                                    associationPath, reqPath, depth,
-                                    interfaces);
-    });
+            return getAssociatedSubTree(interfaceMap, associationMaps,
+                                        associationPath, reqPath, depth,
+                                        interfaces);
+        });
 
     iface->register_method(
         "GetAssociatedSubTreePaths",
         [&interfaceMap](const sdbusplus::message::object_path& associationPath,
                         const sdbusplus::message::object_path& reqPath,
                         int32_t depth, std::vector<std::string>& interfaces) {
-        return getAssociatedSubTreePaths(interfaceMap, associationMaps,
-                                         associationPath, reqPath, depth,
-                                         interfaces);
-    });
+            return getAssociatedSubTreePaths(interfaceMap, associationMaps,
+                                             associationPath, reqPath, depth,
+                                             interfaces);
+        });
 
     iface->initialize();
 
diff --git a/src/processing.cpp b/src/processing.cpp
index f0fcd94..79d79ba 100644
--- a/src/processing.cpp
+++ b/src/processing.cpp
@@ -34,8 +34,8 @@
 
     auto inSkipList = std::find_if(skipNamespaces.begin(), skipNamespaces.end(),
                                    [&processName](auto prefix) {
-        return processName.starts_with(prefix);
-    }) != skipNamespaces.end();
+                                       return processName.starts_with(prefix);
+                                   }) != skipNamespaces.end();
     return !(inSkipList || processName.empty());
 }
 
@@ -97,13 +97,11 @@
     }
 }
 
-void processInterfaceAdded(boost::asio::io_context& io,
-                           InterfaceMapType& interfaceMap,
-                           const sdbusplus::message::object_path& objPath,
-                           const InterfacesAdded& intfAdded,
-                           const std::string& wellKnown,
-                           AssociationMaps& assocMaps,
-                           sdbusplus::asio::object_server& server)
+void processInterfaceAdded(
+    boost::asio::io_context& io, InterfaceMapType& interfaceMap,
+    const sdbusplus::message::object_path& objPath,
+    const InterfacesAdded& intfAdded, const std::string& wellKnown,
+    AssociationMaps& assocMaps, sdbusplus::asio::object_server& server)
 {
     auto& ifaceList = interfaceMap[objPath.str];
 
diff --git a/src/processing.hpp b/src/processing.hpp
index d33f15f..15577ec 100644
--- a/src/processing.hpp
+++ b/src/processing.hpp
@@ -79,10 +79,8 @@
  * @param[in,out] server          - sdbus system object
  *
  */
-void processInterfaceAdded(boost::asio::io_context& io,
-                           InterfaceMapType& interfaceMap,
-                           const sdbusplus::message::object_path& objPath,
-                           const InterfacesAdded& intfAdded,
-                           const std::string& wellKnown,
-                           AssociationMaps& assocMaps,
-                           sdbusplus::asio::object_server& server);
+void processInterfaceAdded(
+    boost::asio::io_context& io, InterfaceMapType& interfaceMap,
+    const sdbusplus::message::object_path& objPath,
+    const InterfacesAdded& intfAdded, const std::string& wellKnown,
+    AssociationMaps& assocMaps, sdbusplus::asio::object_server& server);
diff --git a/src/test/handler.cpp b/src/test/handler.cpp
index 3671977..aac2d0f 100644
--- a/src/test/handler.cpp
+++ b/src/test/handler.cpp
@@ -246,8 +246,8 @@
 {
     std::string path = "/test/object_path_0";
     std::vector<std::string> interfaces = {"bad_interface"};
-    std::vector<std::string> subtreePath = getSubTreePaths(interfaceMap, path,
-                                                           0, interfaces);
+    std::vector<std::string> subtreePath =
+        getSubTreePaths(interfaceMap, path, 0, interfaces);
     ASSERT_TRUE(subtreePath.empty());
 
     path = "/invalid_path";
@@ -263,8 +263,8 @@
     std::vector<std::string> interfaces = {"test_interface_1",
                                            "test_interface_3"};
     // Root
-    std::vector<std::string> subtreePath = getSubTreePaths(interfaceMap, "/", 0,
-                                                           interfaces);
+    std::vector<std::string> subtreePath =
+        getSubTreePaths(interfaceMap, "/", 0, interfaces);
     ASSERT_THAT(subtreePath,
                 ElementsAre("/test/object_path_0/child",
                             "/test/object_path_0/child/grandchild/dog"));
@@ -293,10 +293,10 @@
     std::vector<std::string> validInterfaces = {"test_interface_1",
                                                 "test_interface_2"};
     // Associated path, but invalid interface
-    ASSERT_TRUE(getAssociatedSubTree(interfaceMap, associationMap,
-                                     validAssociatedPath, path, 0,
-                                     invalidInterfaces)
-                    .empty());
+    ASSERT_TRUE(
+        getAssociatedSubTree(interfaceMap, associationMap, validAssociatedPath,
+                             path, 0, invalidInterfaces)
+            .empty());
 
     // Valid interface, not associated
     ASSERT_TRUE(getAssociatedSubTree(interfaceMap, associationMap, path / "dog",
@@ -316,10 +316,10 @@
     sdbusplus::message::object_path path0("/test/object_path_0");
     sdbusplus::message::object_path path1("/test/object_path_0/child");
     sdbusplus::message::object_path associatedPath = path0 / "descendent";
-    std::vector<std::string> interfaces = {"test_interface_1",
-                                           "test_interface_2",
-                                           // Not associated to path
-                                           "test_interface_3"};
+    std::vector<std::string> interfaces = {
+        "test_interface_1", "test_interface_2",
+        // Not associated to path
+        "test_interface_3"};
 
     // Path0
     std::vector<InterfaceMapType::value_type> subtree = getAssociatedSubTree(
@@ -368,10 +368,10 @@
                     .empty());
 
     // Valid interface, not associated
-    ASSERT_TRUE(getAssociatedSubTreePaths(interfaceMap, associationMap,
-                                          path / "dog", path, 0,
-                                          validInterfaces)
-                    .empty());
+    ASSERT_TRUE(
+        getAssociatedSubTreePaths(interfaceMap, associationMap, path / "dog",
+                                  path, 0, validInterfaces)
+            .empty());
 
     // Invalid path, with valid association
     path = sdbusplus::message::object_path("/invalid_path");
@@ -387,10 +387,10 @@
     sdbusplus::message::object_path path0("/test/object_path_0");
     sdbusplus::message::object_path path1("/test/object_path_0/child");
     sdbusplus::message::object_path associatedPath = path0 / "descendent";
-    std::vector<std::string> interfaces = {"test_interface_1",
-                                           "test_interface_2",
-                                           // Not associated to path
-                                           "test_interface_3"};
+    std::vector<std::string> interfaces = {
+        "test_interface_1", "test_interface_2",
+        // Not associated to path
+        "test_interface_3"};
 
     // Path0
     std::vector<std::string> subtreePath = getAssociatedSubTreePaths(
@@ -405,9 +405,9 @@
     ASSERT_THAT(subtreePath, ElementsAre("/test/object_path_0/child"));
 
     // Path1
-    subtreePath = getAssociatedSubTreePaths(interfaceMap, associationMap,
-                                            path1 / "descendent", path1, 0,
-                                            interfaces);
+    subtreePath =
+        getAssociatedSubTreePaths(interfaceMap, associationMap,
+                                  path1 / "descendent", path1, 0, interfaces);
     ASSERT_THAT(subtreePath,
                 ElementsAre("/test/object_path_0/child/grandchild"));
 }
diff --git a/src/test/interfaces_added.cpp b/src/test/interfaces_added.cpp
index 4446e23..63a6a26 100644
--- a/src/test/interfaces_added.cpp
+++ b/src/test/interfaces_added.cpp
@@ -34,8 +34,8 @@
     auto interfaceMap = createDefaultInterfaceMap();
     AssociationMaps assocMaps;
 
-    auto intfAdded = createInterfacesAdded(assocDefsInterface,
-                                           assocDefsProperty);
+    auto intfAdded =
+        createInterfacesAdded(assocDefsInterface, assocDefsProperty);
 
     boost::asio::io_context io;