module ietf-yang-library-augmentation {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-yang-library-augmentation";
  prefix yanglib-aug;

  import ietf-yang-library {
    prefix yanglib;
    reference
      "RFC 8525: YANG library";
  }

  organization
    "IETF NETCONF (Network Configuration) Working Group";
  contact
    "WG Web:   <https://datatracker.ietf.org/wg/netconf/>
     WG List:  <mailto:netconf@ietf.org>

     Author:   Zhuoyao Lin
               <mailto:zephyre888@gmail.com>
               Benoit Claise
               <mailto:benoit.claise@huawei.com>";

  description
    "This module augments the ietf-yang-library defined in [RFC8525] to provide the augmentation list, in order to give sufficient information about the YANG models reverse dependency. It facilitates the process of obtaining the entire dependencies of YANG model.";

  revision 2023-10-27 {
    description
      "Added list augmentation in yang-library/module-set/module to
      make the module store the entire reverse dependency information
      (augmentation and deviation).";
    reference
      "RFC XXXX: Support of augmentation in ietf-yang-library";
  }

  augment "/yanglib:yang-library/yanglib:module-set/yanglib:module" {
    description
      "Augment the augmentation from module info with the module-augmentation grouping" ;
    uses yanglib-aug:module-augmentation;
  }

  /*
   * Groupings
   */

  grouping module-augmentation {
    description
      "This grouping defines a leaf-list that contains the augmentation list.";

  leaf-list augmentation {
      type leafref {
        path "/yanglib:yang-library/yanglib:module-set/yanglib:module/yanglib:name";
      }

      description
        "List of all YANG augmentation modules used by this server to
         modify the conformance of the module associated with this
         entry.  Note that the same module can be used for augmentation
         for multiple modules, so the same entry MAY appear within
         multiple 'module' entries.

         This reference MUST NOT (directly or indirectly)
         refer to the module being augmented.

         Robust clients may want to make sure that they handle a
         situation where a module augments itself (directly or
         indirectly) gracefully.";
    }
  }
}
