<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="draft-feng-netmod-naim-01" submissionType="IETF" category="std" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" indexInclude="true">

<front>
<title abbrev="NAIM">NAIM: A Canonical Semantic Representation for AI-Assisted YANG Modeling and Validation</title><seriesInfo value="draft-feng-netmod-naim-01" stream="IETF" status="standard" name="Internet-Draft"></seriesInfo>
<author initials="C." surname="Feng" fullname="Chong Feng"><organization></organization><address><postal><street></street>
</postal><email>fengchongllly@gmail.com</email>
</address></author><date/>
<area>Operations and Management</area>
<workgroup>NETMOD</workgroup>
<keyword>YANG</keyword>
<keyword>NAIM</keyword>
<keyword>AI</keyword>
<keyword>network management</keyword>

<abstract>
<t>This document defines the NAIM (Natural AI Interface Modeling)
framework, a canonical semantic intermediate representation between
natural language descriptions and YANG data models (RFC 7950).</t>
<t>NAIM addresses a recognized gap in the YANG authoring and network
management workflow: direct conversion from natural language to YANG is
error-prone because essential modeling semantics -- including
configuration versus state distinction, list key identification,
constraint expressions, operational preconditions, and cross-module
relationships -- are routinely absent or ambiguous in natural language
input.  NAIM makes these semantics explicit, structurally consistent,
and machine-verifiable.</t>
<t>This document defines: the NAIM Document format (Canonical JSON and
derived Markdown View); the LLM Context View for AI prompt context
distribution; the three-layer architecture (Specification, Skill, Tool);
Skills A-D for conversational modeling, summarization, YANG generation,
and reverse engineering; and the Validation-Reflection-Retry mechanism
for AI output quality control.</t>
<t>The NAIM Document format is designed to serve two roles: as the
intermediate representation for design-time YANG authoring, and as the
runtime semantic authority against which AI-generated operation intents
are validated.  The runtime validation usage is specified in [NAIM-OP];
this document defines the format, derived views, and design-time
workflows.</t>
</abstract>

</front>

<middle>

<section anchor="introduction"><name>Introduction</name>
<t>The YANG data modeling language [RFC7950] is the foundation of
model-driven network management and is widely deployed in NETCONF
[RFC6241], RESTCONF [RFC8040], and related systems.  Despite its
importance, authoring high-quality YANG modules requires simultaneous
fluency in network protocol behavior, data modeling methodology, and
YANG syntax.  This combination makes YANG authoring a specialized skill
that limits the pace at which network management models can be developed
and maintained.</t>
<t>Recent progress in large language model (LLM) technology has created an
opportunity to partially automate and assist the YANG authoring process.
However, this opportunity cannot be fully realized through direct
conversion from natural language to YANG.  The gap between natural
language and YANG is not primarily syntactic; it is semantic.  Natural
language descriptions routinely omit, conflate, or leave ambiguous
precisely the distinctions that YANG modeling requires.</t>

<section anchor="problem-statement"><name>Problem Statement</name>
<t>Direct conversion from natural language to YANG exhibits three recurring
failure modes.</t>
<t><strong>Semantic ambiguity.</strong>  Natural language descriptions commonly omit
distinctions that are essential to correct YANG modeling.  Whether a
field represents configuration or operational state, whether an entity is
a list keyed by an identifier or a singleton container, and whether two
fields are siblings or parent and child are all questions that a natural
language description frequently leaves unanswered.  Without an explicit
clarification step, an automated tool must guess -- and guesses in
structural modeling propagate into downstream protocol behavior.</t>
<t><strong>Implicit constraint loss.</strong>  Operational constraints, preconditions for
node creation or deletion, cross-node dependencies, and side effects of
configuration changes are often treated as common knowledge in human
discourse and are therefore omitted from natural language descriptions.
YANG models that omit these constraints are structurally valid but
operationally incorrect.</t>
<t><strong>Structural inference errors.</strong>  Hierarchy relationships, augmentation
targets, leafref paths, grouping reuse, and cross-module import
requirements all require precise structural reasoning.  Without a
structured intermediate step, automated tools generate models that
syntactically resemble correct YANG but contain incorrect structural
relationships that are difficult to detect without domain expertise.</t>
</section>

<section anchor="motivation-for-an-intermediate-representation"><name>Motivation for an Intermediate Representation</name>
<t>A structured semantic intermediate representation addresses these
failure modes by externalizing implicit knowledge into a
machine-verifiable form before YANG generation is attempted.  Rather
than asking an automated system to traverse in one step from natural
language to YANG, the workflow is decomposed into two controlled stages:</t>

<ol>
<li><t>Natural language input is converted into a structured, semantically
explicit NAIM Document through a clarification and elicitation
process.  At this stage, missing or ambiguous information is
identified and resolved.</t>
</li>
<li><t>The completed NAIM Document is transformed into a YANG module by
deterministic tooling.  Because the input to this stage is already
structurally explicit and constraint-complete, the transformation
can be made reliable.</t>
</li>
</ol>
<t>The NAIM Document format defined in this document is the artifact that
bridges these two stages.  It is designed to be simultaneously suitable
for automated processing, human review, and version control.</t>
<t>It is important to note that NAIM is not a JSON encoding of YANG.  A
NAIM Document can be transformed into YANG, but it carries semantics
that YANG syntax does not represent, including operational descriptions,
explanatory context, usage examples, cross-node relationship
descriptions, and visibility conditions expressed in natural language.
YANG is a target output of the NAIM workflow, not a semantic equivalent
of NAIM.</t>
</section>

<section anchor="relationship-to-yang"><name>Relationship to YANG</name>
<t>NAIM is not a replacement for YANG.  YANG [RFC7950] remains the
authoritative data modeling language for network management, and the
ultimate source of truth for configuration semantics, protocol
operations, and data constraints.  NAIM is positioned as a semantic
bridge between natural language (or high-level intent) and the YANG
ecosystem, designed to bring the existing YANG infrastructure into the
era of AI-assisted network management.</t>
<t>The YANG ecosystem -- including YANG validators, NETCONF/RESTCONF
servers, and the large body of standardized and vendor YANG modules --
represents more than a decade of modeling investment and operational
deployment.
NAIM does not seek to duplicate or supplant this ecosystem.  Instead,
NAIM provides a structured intermediate representation that enables AI
systems to interact with YANG-based infrastructure more reliably, by
making the implicit modeling knowledge required for YANG authoring
explicit and machine-processable.</t>
<t>The relationship can be characterized as follows:</t>

<ul>
<li><t><strong>YANG is the target, NAIM is the path.</strong>  Every NAIM Document is
designed to be transformed into a valid YANG module (design-time) or
validated against YANG-derived semantics (runtime).  NAIM exists to
improve the quality and reliability of this transformation, not to
serve as an independent modeling language.</t>
</li>
<li><t><strong>YANG-based systems remain the authoritative validators.</strong>  NAIM
performs structural and formal validation: schema conformance, type
checking, required field presence, path format correctness, and node
template completeness.  However, true semantic validation --
including <tt>must</tt> and <tt>when</tt> expression evaluation, <tt>leafref</tt> target
resolution, instance-level data validation, and cross-module
augmentation consistency -- remains the responsibility of YANG-based
systems such as YANG validators, NETCONF servers, and RESTCONF
servers.  A NAIM Document that passes NAIM-level validation is not
guaranteed to produce a YANG module that will pass all semantic
checks in a target YANG-based system.</t>
</li>
<li><t><strong>NAIM enables YANG ecosystem evolution.</strong>  By providing a
representation that is simultaneously suitable for AI consumption
and deterministic YANG generation, NAIM enables the YANG ecosystem
to benefit from advances in AI-assisted design, natural language
interaction, and automated modeling -- without requiring changes to
the YANG language itself or to existing YANG-based infrastructure.</t>
</li>
</ul>
</section>

<section anchor="dual-purpose-design"><name>Dual-Purpose Design</name>
<t>While the primary workflow described in this document is design-time
YANG authoring (natural language -&gt; NAIM Document -&gt; YANG), the NAIM
Document format is deliberately designed to serve a second role: as the
runtime semantic authority against which AI-generated operation intents
are validated.</t>
<t>The operational semantics carried in NAIM Documents -- preconditions,
side effects, constraints, and writable status -- enable deterministic
validation of structured operation objects produced by AI systems,
without requiring the AI to be trusted for execution decisions.  This
explains why the NAIM Document format carries fields such as
<tt>operations.preconditions</tt> and <tt>operations.side-effects</tt> that go beyond
what is strictly needed for YANG generation: they serve as
machine-processable validation rules at runtime.</t>
<t>This runtime usage is specified in [NAIM-OP]; the present document
defines only the format and its design-time workflows.  The two
documents together implement a complete pipeline from natural language
intent to validated network execution:</t>

<artwork><![CDATA[Design-time:  Natural Language -> NAIM Document -> YANG
Runtime:      Natural Language -> Operation IR -> [validated against
              NAIM Document] -> NETCONF/RESTCONF execution
]]></artwork>
</section>

<section anchor="scope-of-this-document"><name>Scope of This Document</name>
<t>This document defines the NAIM framework.  It is intended for
implementors who build tools that produce, validate, transform, or
consume NAIM Documents, and for protocol engineers who wish to understand
the semantic representation choices made by the format.</t>
<t>This document defines:</t>

<ul spacing="compact">
<li>the NAIM Document format (Canonical JSON and Markdown View);</li>
<li>the LLM Context View (derived format for AI prompt context);</li>
<li>the three-layer architecture (Specification, Skill, Tool);</li>
<li>Skills A-D (Conversational Modeling, Summarization, YANG Generation,
Reverse Engineering);</li>
<li>the Validation-Reflection-Retry mechanism; and</li>
<li>interoperability expectations for tools that exchange NAIM artifacts.</li>
</ul>
<t>This document does not specify a specific AI model or LLM backend,
prompt engineering strategies, confidence scoring algorithms,
implementation-internal workflow logic, or runtime network operation
execution.</t>
</section>
</section>

<section anchor="requirements-language"><name>Requirements Language</name>
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL NOT&quot;,
&quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;NOT RECOMMENDED&quot;, &quot;MAY&quot;, and
&quot;OPTIONAL&quot; in this document are to be interpreted as described in BCP 14
[RFC2119] [RFC8174] when, and only when, they appear in all capitals, as
shown here.</t>
</section>

<section anchor="terminology"><name>Terminology</name>
<t><strong>NAIM</strong>: Natural AI Interface Modeling.</t>
<t><strong>NAIM Document</strong>: A structured artifact conforming to the canonical
JSON schema defined in this document.  A NAIM Document represents the
semantics of one YANG module or one YANG submodule.</t>
<t><strong>Canonical JSON Format</strong>: The normative JSON representation of a NAIM
Document.  All interoperable tools MUST treat the canonical JSON format
as the authoritative source of NAIM Document content.</t>
<t><strong>Markdown View</strong>: A human-readable rendering derived from the canonical
JSON representation.  The Markdown View is a presentation artifact; it
is not normatively authoritative over the canonical JSON.</t>
<t><strong>LLM Context View</strong>: A derived, token-efficient Markdown format
intended for consumption by AI systems as prompt context.  Retains
semantic fields while omitting structural boilerplate and execution
details.  See Section 7.</t>
<t><strong>Node Template</strong>: A structured schema pattern describing one category
of semantic model node within a NAIM Document.</t>
<t><strong>Visibility Condition</strong>: A declaration associated with a node that
specifies the conditions under which the node is present or applicable.
Corresponds to YANG <tt>if-feature</tt> and <tt>when</tt> constructs.</t>
<t><strong>Deviation Declaration</strong>: A structured statement describing the ways in
which a specific device implementation departs from a base YANG module.</t>
<t><strong>Skill</strong>: A named, versioned, independently customizable process
specification that defines the inputs, outputs, and behavioral rules
for one stage of the NAIM workflow.  Skills do not implement AI models;
they specify what AI participation looks like.</t>
<t><strong>Structured Error Report</strong>: A machine-readable error object produced by
the Tool Layer when validation fails, containing error type, path,
message, and expected format.</t>
</section>

<section anchor="architectural-framework"><name>Architectural Framework</name>
<t>NAIM is organized as a three-layer architecture that separates concerns
between specification, AI-driven processes, and deterministic execution.</t>

<section anchor="three-layer-model"><name>Three-Layer Model</name>

<artwork><![CDATA[                    +-----------------------+
                    |   Skill Layer         |
                    |   (AI-driven)         |
                    |   Skills A, B, C, D   |
                    +-----------+-----------+
                                |
                 consumes       |    produces
                 Specification  |    NAIM Documents
                                |
    +------------------+        |        +------------------+
    | Specification    |--------+------->| Tool Layer       |
    | Layer            |                 | (deterministic)  |
    | (format + rules) |<----------------| validation,      |
    +------------------+   validates     | generation,      |
                           against       | conversion       |
                                         +------------------+
]]></artwork>
</section>

<section anchor="specification-layer"><name>Specification Layer</name>
<t>The Specification Layer defines the NAIM Document format itself:</t>

<ul spacing="compact">
<li>Canonical JSON structure and JSON Schema;</li>
<li>Node template families;</li>
<li>Type representation rules;</li>
<li>Path conventions;</li>
<li>Markdown View and LLM Context View generation rules.</li>
</ul>
<t>This is the static normative layer.  Sections 5-14 of this document
constitute the Specification Layer.</t>
</section>

<section anchor="skill-layer"><name>Skill Layer</name>
<t>The Skill Layer defines the AI-driven processes that operate on NAIM
Documents.  Each Skill specifies:</t>

<ul spacing="compact">
<li>what its inputs and outputs are;</li>
<li>what conditions must hold before it can proceed;</li>
<li>what behavioral rules govern AI participation.</li>
</ul>
<t>Skills are decoupled from the Specification Layer: the format can remain
stable while Skill implementations are versioned and customized
independently for different user populations and deployment contexts.
For example, the same NAIM Specification can support a simplified
question flow for network operators and an expert-mode flow for protocol
engineers.</t>
<t>This document defines four Skills (Section 15):</t>

<ul spacing="compact">
<li>Skill A: Conversational Modeling</li>
<li>Skill B: Natural Language Summarization</li>
<li>Skill C: YANG Generation</li>
<li>Skill D: Reverse Engineering</li>
</ul>
</section>

<section anchor="tool-layer"><name>Tool Layer</name>
<t>The Tool Layer performs deterministic operations on NAIM Documents.
Tools are not AI systems; they are conventional software components that
provide correctness guarantees that AI systems cannot.</t>
<t>Tool Layer responsibilities:</t>

<ul spacing="compact">
<li>JSON Schema validation of NAIM Documents;</li>
<li>Structured Error Report generation for validation failures;</li>
<li>Bidirectional conversion between Canonical JSON and Markdown View;</li>
<li>Generation of LLM Context Views from Canonical JSON;</li>
<li>Compilation of YANG modules from confirmed NAIM Documents;</li>
<li>Structural extraction from existing YANG modules (for Skill D).</li>
</ul>
</section>

<section anchor="validation-reflection-retry-mechanism"><name>Validation-Reflection-Retry Mechanism</name>
<t>When the Tool Layer detects validation errors in AI-generated NAIM
Documents, the following three-phase error correction mechanism applies.</t>

<section anchor="phase-1-structured-error-report"><name>Phase 1: Structured Error Report</name>
<t>The Tool Layer MUST emit a Structured Error Report containing:</t>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>

<tbody>
<tr>
<td><tt>error_code</tt></td>
<td>Machine-readable error category, e.g., <tt>MissingRequiredField</tt>, <tt>InvalidPathFormat</tt>, <tt>TypeConstraintViolation</tt></td>
</tr>

<tr>
<td><tt>path</tt></td>
<td>JSON Pointer [RFC6901] to the failing field, e.g., <tt>/nodes/2/type</tt></td>
</tr>

<tr>
<td><tt>message</tt></td>
<td>Human-readable error description, suitable for AI consumption</td>
</tr>

<tr>
<td><tt>expected</tt></td>
<td>Expected format or valid value range</td>
</tr>
</tbody>
</table><t>Example:</t>

<sourcecode type="json"><![CDATA[{
  "error_code": "MissingRequiredField",
  "path": "/nodes/1/type",
  "message": "Node at path '/eth-interface:interfaces/
    interface/bandwidth' is of node-type 'leaf' but is
    missing required field 'type'.",
  "expected": "A type object with at least a 'base' field,
    e.g., {\"base\": \"uint32\"}"
}
]]></sourcecode>
</section>

<section anchor="phase-2-context-injection-and-silent-retry"><name>Phase 2: Context Injection and Silent Retry</name>
<t>The system SHOULD automatically inject the Structured Error Report into
the Skill's prompt context and retry generation.  The retry process
SHOULD be transparent to the user: the Skill regenerates corrected
output and resubmits it for Tool Layer validation without user
intervention.</t>
</section>

<section anchor="phase-3-maximum-retry-and-degradation"><name>Phase 3: Maximum Retry and Degradation</name>
<t>The system MUST enforce a maximum automatic retry count (RECOMMENDED
value: 3).  If retries are exhausted and validation still fails:</t>

<ul spacing="compact">
<li>The system MUST stop automatic retries;</li>
<li>The active Skill MUST convert the remaining errors into targeted
natural language questions directed at the user;</li>
<li>The user MUST receive a clear indication of what specific field or
constraint the system could not resolve automatically;</li>
<li>The entire error correction history SHOULD be recorded in audit logs.</li>
</ul>
</section>
</section>
</section>

<section anchor="naim-document-format"><name>NAIM Document Format</name>

<section anchor="canonical-json-as-normative-source"><name>Canonical JSON as Normative Source</name>
<t>A NAIM Document MUST be represented as a JSON object [RFC8259] that
conforms to the schema expectations defined in this document.</t>
<t>The canonical JSON representation is the normative source of NAIM
Document content.  All interoperable tools that exchange NAIM Documents
MUST treat the canonical JSON format as authoritative.  The Markdown
View defined in Section 6 is a derived presentation artifact; it does
not override the canonical JSON.  When any discrepancy exists between
the canonical JSON and a corresponding Markdown View, the canonical JSON
MUST take precedence.</t>
</section>

<section anchor="top-level-object-structure"><name>Top-Level Object Structure</name>
<t>The top-level JSON object of a NAIM Document MUST contain:</t>

<ul spacing="compact">
<li><tt>version</tt>: A string identifying the NAIM format version.  For
documents conforming to this specification, the value MUST be <tt>&quot;1.0&quot;</tt>.</li>
<li>Exactly one of <tt>module</tt> or <tt>submodule</tt>.  A top-level object MUST NOT
contain both.</li>
</ul>
<t>The top-level object MAY additionally contain any of the following
arrays:</t>

<ul spacing="compact">
<li><tt>revisions</tt></li>
<li><tt>features</tt></li>
<li><tt>typedefs</tt></li>
<li><tt>groupings</tt></li>
<li><tt>identities</tt></li>
<li><tt>extensions</tt></li>
<li><tt>nodes</tt></li>
</ul>
<t>A conforming NAIM Document representing usable model content SHOULD
contain a <tt>nodes</tt> array with at least one node object.</t>
</section>

<section anchor="the-module-object"><name>The <tt>module</tt> Object</name>
<t>When the top-level object contains <tt>module</tt>, it represents a YANG main
module.  The <tt>module</tt> object MUST contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: A string.  The YANG module name.  It MUST conform to the
identifier syntax defined in Section 6.2 of [RFC7950].</li>
<li><tt>description</tt>: A string.  A human-readable description of the
module's purpose and scope.</li>
</ul>
<t>The <tt>module</tt> object MAY contain:</t>

<ul spacing="compact">
<li><tt>organization</tt>: A string identifying the organization responsible for
the module.</li>
<li><tt>contact</tt>: A string providing contact information for the module.</li>
<li><tt>reference</tt>: A string citing an external document relevant to the
module.</li>
<li><tt>deviations</tt>: An array of deviation objects as defined in Section 12.</li>
</ul>
</section>

<section anchor="the-submodule-object"><name>The <tt>submodule</tt> Object</name>
<t>When the top-level object contains <tt>submodule</tt>, it represents a YANG
submodule.  The <tt>submodule</tt> object MUST contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: A string.  The submodule name.</li>
<li><tt>belongs-to</tt>: A string.  The name of the YANG main module to which
this submodule belongs.</li>
</ul>
<t>The <tt>submodule</tt> object MAY contain:</t>

<ul spacing="compact">
<li><tt>description</tt>: A string.</li>
</ul>
<t>A NAIM Document containing a <tt>submodule</tt> object MUST NOT also contain a
<tt>module</tt> object at the top level.</t>
</section>

<section anchor="top-level-arrays"><name>Top-Level Arrays</name>

<section anchor="revisions"><name><tt>revisions</tt></name>
<t>The <tt>revisions</tt> array MAY be present.  Each entry in the array MUST
contain:</t>

<ul spacing="compact">
<li><tt>revision</tt>: A string in the format <tt>YYYY-MM-DD</tt> representing the
revision date.</li>
<li><tt>description</tt>: A string describing what changed in this revision.</li>
</ul>
<t>Each entry MAY also contain:</t>

<ul spacing="compact">
<li><tt>reference</tt>: A string citing an external document.</li>
</ul>
</section>

<section anchor="features"><name><tt>features</tt></name>
<t>The <tt>features</tt> array MAY be present.  Each entry represents a YANG
feature and MUST contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: A string.  The feature name.</li>
<li><tt>description</tt>: A string describing the feature.</li>
</ul>
<t>Each entry MAY also contain:</t>

<ul spacing="compact">
<li><tt>status</tt>: A string.  If present, it MUST be one of <tt>&quot;current&quot;</tt>,
<tt>&quot;deprecated&quot;</tt>, or <tt>&quot;obsolete&quot;</tt>.</li>
<li><tt>reference</tt>: A string.</li>
</ul>
</section>

<section anchor="typedefs"><name><tt>typedefs</tt></name>
<t>The <tt>typedefs</tt> array MAY be present.  Each entry defines a reusable
type.  See Section 9.1.</t>
</section>

<section anchor="groupings"><name><tt>groupings</tt></name>
<t>The <tt>groupings</tt> array MAY be present.  Each entry defines a reusable
structural fragment.  See Section 9.2.</t>
</section>

<section anchor="identities"><name><tt>identities</tt></name>
<t>The <tt>identities</tt> array MAY be present.  Each entry defines a YANG
identity.  See Section 9.3.</t>
</section>

<section anchor="extensions"><name><tt>extensions</tt></name>
<t>The <tt>extensions</tt> array MAY be present.  Each entry defines an extension
keyword.  See Section 9.4.  Extension use within nodes is described in
Section 13.</t>
</section>

<section anchor="nodes"><name><tt>nodes</tt></name>
<t>The <tt>nodes</tt> array MAY be present.  Each entry is a node object
conforming to one of the node template families defined in Section 8.
The <tt>nodes</tt> array is the primary structural content of a NAIM Document.
When present, it MUST contain only objects that conform to a recognized
node template family.</t>
</section>
</section>

<section anchor="path-conventions"><name>Path Conventions</name>
<t>All <tt>path</tt> fields in node objects MUST be expressed as absolute schema
paths using the following conventions:</t>

<ul spacing="compact">
<li>The path MUST begin with <tt>/</tt>.</li>
<li>Path segments representing nodes in a specific YANG module MUST be
qualified with the module name as a prefix, using the colon (<tt>:</tt>)
separator.  For example: <tt>/ietf-interfaces:interfaces/interface</tt>.</li>
<li>The prefix used MUST be the YANG module name, not the YANG prefix
shorthand.  This ensures path stability across implementations that
may choose different YANG prefix values.</li>
<li>For list nodes, key predicates SHOULD be omitted in schema paths but
MAY be included when a specific instance is referenced in an
operational context outside the scope of this data format.</li>
</ul>
<t>Tools that generate YANG from a NAIM Document MAY derive YANG prefix
shorthand and corresponding <tt>import</tt> statements from the module-name
prefixes used in path fields, without requiring explicit import
declarations in the NAIM Document.</t>
</section>
</section>

<section anchor="markdown-view"><name>Markdown View</name>

<section anchor="purpose-and-normative-status"><name>Purpose and Normative Status</name>
<t>The Markdown View is a human-readable rendering of a NAIM Document,
intended for human review, version-controlled document exchange, and
editorial discussion.  The Markdown View is a derived artifact; it is
not independently normative.</t>
<t>Implementations that produce a Markdown View MUST derive it
deterministically from the canonical JSON.  Implementations that accept
a Markdown View as input MAY use it to construct or update a canonical
JSON document, subject to the constraints in Section 6.2.</t>
</section>

<section anchor="source-of-truth-principle"><name>Source of Truth Principle</name>
<t>The canonical JSON representation is the sole authoritative source of
NAIM Document content.</t>
<t>When a Markdown View is used as input to reconstruct or update a
canonical JSON document, implementations MUST NOT silently discard
existing canonical JSON content.  Specifically:</t>

<ul spacing="compact">
<li>Fields present in the canonical JSON but absent from the Markdown View
MUST be preserved in the resulting canonical JSON unless the Markdown
View contains an explicit deletion signal defined by the
implementation.</li>
<li>If the Markdown View and the canonical JSON express conflicting values
for the same field, the implementation MUST resolve the conflict
explicitly.  The RECOMMENDED resolution strategy is to treat the
Markdown View as expressing only the fields it explicitly represents,
leaving all other canonical JSON fields unchanged.</li>
</ul>
</section>

<section anchor="header-rules"><name>Header Rules</name>
<t>A Markdown View MUST begin with a document header.  The header rules
are:</t>

<ul spacing="compact">
<li>For a main module document, the first line MUST be:
<tt># module: {name}</tt></li>
<li>For a submodule document, the first line MUST be:
<tt># submodule: {name}</tt>
and the second line MUST be:
<tt>## belongs-to: {parent-module-name}</tt></li>
<li>The module or submodule description SHOULD immediately follow as:
<tt>## description: {description}</tt></li>
</ul>
</section>

<section anchor="md-section-blocks"><name>Section Blocks</name>
<t>For each top-level array that is present in the canonical JSON, the
Markdown View SHOULD include a corresponding section.  Section headings
SHOULD be:</t>

<ul spacing="compact">
<li><tt>## Revisions</tt></li>
<li><tt>## Features</tt></li>
<li><tt>## Typedefs</tt></li>
<li><tt>## Groupings</tt></li>
<li><tt>## Identities</tt></li>
<li><tt>## Extensions</tt></li>
</ul>
<t>Each section SHOULD present its entries in list form, with enough detail
to allow a reader to understand the content without reference to the
canonical JSON.</t>
</section>

<section anchor="tree-diagram"><name>Tree Diagram</name>
<t>The Markdown View SHOULD include a tree diagram following the section
blocks and preceding the node definitions.  The tree diagram is an
informative visual aid only; it is not a normative representation of the
schema.</t>
<t>The tree diagram SHOULD follow the YANG tree diagram conventions
described in [RFC8340], using ASCII art to represent schema hierarchy.
Conventions include:</t>

<ul spacing="compact">
<li><tt>+--rw</tt> for read-write nodes,</li>
<li><tt>+--ro</tt> for read-only nodes,</li>
<li><tt>*</tt> to indicate list nodes, and</li>
<li><tt>?</tt> to indicate optional nodes.</li>
</ul>
<t>Because the tree diagram is informative and not used for round-trip
reconstruction, implementations MAY omit it or vary its format.</t>
</section>

<section anchor="flat-node-definitions"><name>Flat Node Definitions</name>
<t>Following the tree diagram, the Markdown View MUST include a flat
definition block for each node in the <tt>nodes</tt> array.  The flat
definition format MUST follow these rules:</t>

<ul spacing="compact">
<li>Each node definition MUST begin with a heading of the form:
<tt>### {local-name} ({node-type})</tt>
where <tt>{local-name}</tt> is the last path segment of the node's <tt>path</tt>
field and <tt>{node-type}</tt> is the value of the node's <tt>node-type</tt> field.</li>
<li>Node fields SHOULD be rendered in the following order when present:
<tt>path</tt>, <tt>description</tt>, <tt>type</tt>, <tt>writable</tt>, <tt>key</tt>, <tt>operations</tt>,
<tt>visibility</tt>, <tt>related-nodes</tt>, <tt>constraints</tt>, <tt>examples</tt>.</li>
<li>Nodes MUST be presented in depth-first traversal order derived from
their <tt>path</tt> field values.</li>
</ul>
</section>

<section anchor="round-trip-requirements"><name>Round-Trip Requirements</name>
<t>The combination of canonical JSON and the Markdown View MUST satisfy the
following round-trip property: given a canonical JSON document <tt>J</tt>, a
Markdown View <tt>M</tt> derived from <tt>J</tt>, and a reconstruction process <tt>R</tt>
that produces JSON from <tt>M</tt>, the result <tt>R(M)</tt> MUST be semantically
equivalent to <tt>J</tt> for all fields that the Markdown View represents.</t>
<t>Implementations MUST NOT produce Markdown Views in which the rendering
of any represented field loses information relative to the canonical
JSON representation of that field.</t>
</section>
</section>

<section anchor="llm-context-view"><name>LLM Context View</name>

<section anchor="purpose"><name>Purpose</name>
<t>The LLM Context View is a derived Markdown format optimized for
consumption by AI systems as prompt context.  It is
designed to provide the semantic information an AI system needs to
generate correct Operation IRs [NAIM-OP] or to participate in NAIM
Skills, while minimizing token consumption.</t>
<t>The LLM Context View is distinct from the Markdown View defined in
Section 6: the Markdown View is designed for human review and round-trip
fidelity; the LLM Context View is designed for AI consumption and token
efficiency.</t>
</section>

<section anchor="mandatory-fields"><name>Mandatory Fields</name>
<t>An LLM Context View MUST include:</t>

<ul spacing="compact">
<li>resource/node name and node-type;</li>
<li>all field names with semantic types, required/optional status
(derived from the <tt>mandatory</tt> field for leaf and leaf-list nodes, and
from <tt>min-elements</tt> for leaf-list and list nodes), and constraints;</li>
<li>writable status for each field;</li>
<li>visibility conditions (if-feature, when) that affect field
availability;</li>
<li>supported operations for container and list nodes, derived from the
<tt>operations</tt> object defined in Section 8.3;</li>
<li>for each operation: preconditions and side effects;</li>
<li>illustrative examples where present in the canonical JSON; and</li>
<li>the Operation IR schema reference URI, when the LLM Context View is
used for runtime operation intent generation.</li>
</ul>
</section>

<section anchor="omitted-fields"><name>Omitted Fields</name>
<t>The following MUST be omitted from all LLM Context Views:</t>

<ul spacing="compact">
<li>NETCONF XML / RESTCONF request construction details;</li>
<li>internal metadata (version, organization, ownership);</li>
<li>raw JSON Schema syntax of the Canonical JSON;</li>
<li>deviation declarations (these are server-internal concerns); and</li>
<li>extension definitions (only extension uses relevant to visible nodes
are retained).</li>
</ul>
</section>

<section anchor="generation-rules"><name>Generation Rules</name>
<t>Implementations that produce LLM Context Views MUST derive them
deterministically from the canonical JSON.  Given the same canonical
JSON input, all conforming implementations MUST produce semantically
equivalent LLM Context Views.</t>
<t>The LLM Context View is a derived, non-authoritative format.  It MUST
NOT be used as input to reconstruct canonical JSON documents.  The
round-trip requirement defined in Section 6.7 does not apply to LLM
Context Views.</t>
</section>
</section>

<section anchor="node-template-families"><name>Node Template Families</name>
<t>A node object in the <tt>nodes</tt> array MUST conform to one of the node
template families defined in this section.  Each node object MUST
contain a <tt>node-type</tt> field whose value identifies the applicable
template family.</t>

<section anchor="common-semantic-fields"><name>Common Semantic Fields</name>
<t>The following fields MAY appear in any node object regardless of its
template family:</t>

<ul spacing="compact">
<li><tt>path</tt> (string, REQUIRED for all node templates): The absolute schema
path of this node, following the conventions in Section 5.6.</li>
<li><tt>description</tt> (string, REQUIRED for all node templates): A
human-readable description of the node's purpose, semantics, and
operational meaning.</li>
<li><tt>visibility</tt> (object, OPTIONAL): Conditions under which this node is
present or applicable.  See Section 11.</li>
<li><t><tt>related-nodes</tt> (array, OPTIONAL): References to other nodes that are
semantically related to this node.  Each entry SHOULD contain:</t>

<ul spacing="compact">
<li><tt>path</tt>: The absolute schema path of the related node.</li>
<li><tt>relationship</tt>: A human-readable description of the relationship.</li>
</ul></li>
<li><tt>constraints</tt> (string or object, OPTIONAL): Operational constraints
applying to this node beyond what the type system expresses.  It MAY
be a natural-language string or an object with <tt>xpath</tt> and
<tt>description</tt> fields.</li>
<li><t><tt>examples</tt> (array, OPTIONAL): Usage examples.  Each entry SHOULD
contain:</t>

<ul spacing="compact">
<li><tt>scenario</tt>: A description of the scenario.</li>
<li><tt>operation</tt>: A value or operation illustrating the scenario.</li>
</ul></li>
<li><tt>status</tt> (string, OPTIONAL): The lifecycle status of this node.  If
present, it MUST be one of <tt>&quot;current&quot;</tt>, <tt>&quot;deprecated&quot;</tt>, or
<tt>&quot;obsolete&quot;</tt>.  Corresponds to the YANG <tt>status</tt> statement.  Defaults
to <tt>&quot;current&quot;</tt> if absent.</li>
<li><tt>extensions</tt> (array, OPTIONAL): Extension annotations applied to this
node.  Each entry MUST conform to the extension-use object structure
defined in Section 13.</li>
</ul>
</section>

<section anchor="leaf-and-leaf-list"><name><tt>leaf</tt> and <tt>leaf-list</tt></name>
<t>A node object with <tt>node-type</tt> value <tt>&quot;leaf&quot;</tt> or <tt>&quot;leaf-list&quot;</tt>
represents a YANG leaf or leaf-list node.</t>
<t>REQUIRED fields:</t>

<ul spacing="compact">
<li><tt>node-type</tt></li>
<li><tt>path</tt></li>
<li><tt>description</tt></li>
<li><tt>type</tt>: An object describing the data type.  See Section 10.</li>
<li><tt>writable</tt>: A boolean.  <tt>true</tt> indicates a configuration node; <tt>false</tt>
indicates a state node.</li>
</ul>
<t>OPTIONAL fields:</t>

<ul spacing="compact">
<li><tt>mandatory</tt>: A boolean.  If <tt>true</tt>, this node MUST be present when its
parent exists.  Corresponds to the YANG <tt>mandatory</tt> statement.
Defaults to <tt>false</tt> if absent.  Applicable to <tt>leaf</tt> only; for
<tt>leaf-list</tt>, cardinality is expressed via <tt>min-elements</tt>.</li>
<li><tt>min-elements</tt> (applicable to <tt>leaf-list</tt> only): An integer.  The
minimum number of entries that MUST be present.  Corresponds to the
YANG <tt>min-elements</tt> statement.</li>
<li><tt>max-elements</tt> (applicable to <tt>leaf-list</tt> only): An integer or the
string <tt>&quot;unbounded&quot;</tt>.  The maximum number of entries permitted.
Corresponds to the YANG <tt>max-elements</tt> statement.</li>
<li><tt>ordered-by</tt> (applicable to <tt>leaf-list</tt> only): A string.  If present,
it MUST be one of <tt>&quot;system&quot;</tt> or <tt>&quot;user&quot;</tt>.  Corresponds to the YANG
<tt>ordered-by</tt> statement.  Defaults to <tt>&quot;system&quot;</tt> if absent.</li>
</ul>
<t>All common semantic fields defined in Section 8.1 apply.</t>
</section>

<section anchor="container-and-list"><name><tt>container</tt> and <tt>list</tt></name>
<t>A node object with <tt>node-type</tt> value <tt>&quot;container&quot;</tt> or <tt>&quot;list&quot;</tt>
represents a YANG container or list node.</t>
<t>REQUIRED fields:</t>

<ul spacing="compact">
<li><tt>node-type</tt></li>
<li><tt>path</tt></li>
<li><tt>description</tt></li>
<li><tt>writable</tt>: A boolean.</li>
<li><tt>key</tt> (REQUIRED when <tt>node-type</tt> is <tt>&quot;list&quot;</tt> and <tt>writable</tt> is
<tt>true</tt>): A string containing the space-separated list key leaf names.
This reflects the YANG requirement that a key statement MUST be
present if the list represents configuration [RFC7950, Section 7.8.2].
A state list (<tt>writable</tt> is <tt>false</tt>) MAY omit the <tt>key</tt> field.</li>
</ul>
<t>OPTIONAL fields:</t>

<ul spacing="compact">
<li><tt>uses</tt>: A string reference to a grouping defined in the <tt>groupings</tt>
array.</li>
<li><t><tt>operations</tt>: An object describing operational semantics.  It SHOULD
contain:</t>

<ul spacing="compact">
<li><tt>preconditions</tt>: A string describing conditions that must hold
before this node can be created or modified.</li>
<li><tt>side-effects</tt>: A string describing the effects of creating,
modifying, or deleting this node.</li>
</ul></li>
<li><tt>presence</tt> (applicable to <tt>container</tt> only): A string.  If present,
this container is a YANG presence container, and the string value is
the meaning of the container's presence.  Corresponds to the YANG
<tt>presence</tt> statement.  If absent, the container is a non-presence
(structural) container.</li>
<li><tt>min-elements</tt> (applicable to <tt>list</tt> only): An integer.  The minimum
number of list entries that MUST be present.  Corresponds to the YANG
<tt>min-elements</tt> statement.</li>
<li><tt>max-elements</tt> (applicable to <tt>list</tt> only): An integer or the string
<tt>&quot;unbounded&quot;</tt>.  The maximum number of list entries permitted.
Corresponds to the YANG <tt>max-elements</tt> statement.</li>
<li><tt>unique</tt> (applicable to <tt>list</tt> only): An array of strings.  Each
string is a space-separated list of descendant schema node identifiers
that MUST be unique across all list entries.  Corresponds to the YANG
<tt>unique</tt> statement.</li>
<li><tt>ordered-by</tt> (applicable to <tt>list</tt> only): A string.  If present, it
MUST be one of <tt>&quot;system&quot;</tt> or <tt>&quot;user&quot;</tt>.  Corresponds to the YANG
<tt>ordered-by</tt> statement.  Defaults to <tt>&quot;system&quot;</tt> if absent.</li>
</ul>
<t>All common semantic fields defined in Section 8.1 apply.</t>
<t><strong>Key leaf consistency rule.</strong>  When <tt>node-type</tt> is <tt>&quot;list&quot;</tt>, each leaf
node identified in the <tt>key</tt> field MUST have its <tt>writable</tt> value
equal to the <tt>writable</tt> value of the enclosing list node.  This
reflects the YANG requirement that a key leaf's <tt>config</tt> value MUST
match that of its parent list [RFC7950, Section 7.8.2].  The Tool
Layer MUST reject NAIM Documents that violate this rule.</t>
</section>

<section anchor="choice"><name><tt>choice</tt></name>
<t>A node object with <tt>node-type</tt> value <tt>&quot;choice&quot;</tt> represents a YANG
choice node containing mutually exclusive alternatives.</t>
<t>A <tt>case</tt> is not an independent node-type value.  Cases are represented
inline within the <tt>cases</tt> array of the enclosing <tt>choice</tt> node object
and do not appear as separate entries in the <tt>nodes</tt> array.</t>
<t>REQUIRED fields:</t>

<ul spacing="compact">
<li><tt>node-type</tt></li>
<li><tt>path</tt></li>
<li><tt>description</tt></li>
<li><t><tt>cases</tt>: An array of case objects.  Each case object MUST contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: The case name.</li>
<li><tt>nodes</tt>: An array of absolute schema paths identifying the nodes
belonging to this case.
Each case object SHOULD also contain:</li>
<li><tt>description</tt>: A string.</li>
</ul></li>
</ul>
<t>OPTIONAL fields:</t>

<ul spacing="compact">
<li><tt>mandatory</tt>: A boolean.  If <tt>true</tt>, exactly one case MUST be selected.</li>
</ul>
<t>All common semantic fields defined in Section 8.1 apply.</t>
</section>

<section anchor="rpc-and-action"><name><tt>rpc</tt> and <tt>action</tt></name>
<t>A node object with <tt>node-type</tt> value <tt>&quot;rpc&quot;</tt> or <tt>&quot;action&quot;</tt> represents a
YANG RPC or action node.</t>
<t>REQUIRED fields:</t>

<ul spacing="compact">
<li><tt>node-type</tt></li>
<li><tt>path</tt></li>
<li><tt>description</tt></li>
</ul>
<t>OPTIONAL fields:</t>

<ul spacing="compact">
<li><tt>input</tt>: A string giving the absolute schema path of the input
container.</li>
<li><tt>output</tt>: A string giving the absolute schema path of the output
container.</li>
<li><tt>preconditions</tt>: A string describing conditions required before
invocation.</li>
<li><tt>side-effects</tt>: A string describing effects of successful invocation.</li>
<li><tt>error-conditions</tt>: A string describing conditions under which the
operation fails.</li>
</ul>
<t>All common semantic fields defined in Section 8.1 apply.</t>
</section>

<section anchor="notification"><name><tt>notification</tt></name>
<t>A node object with <tt>node-type</tt> value <tt>&quot;notification&quot;</tt> represents a YANG
notification node.</t>
<t>REQUIRED fields:</t>

<ul spacing="compact">
<li><tt>node-type</tt></li>
<li><tt>path</tt></li>
<li><tt>description</tt></li>
</ul>
<t>OPTIONAL fields:</t>

<ul spacing="compact">
<li><tt>trigger</tt>: A string describing the condition that causes this
notification to be emitted.</li>
<li><t><tt>data</tt>: An array of objects, each describing a data item carried by
the notification.  Each entry SHOULD contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: The item name.</li>
<li><tt>type</tt>: The item type.</li>
<li><tt>description</tt>: A description.</li>
</ul></li>
<li><tt>side-effects</tt>: A string describing effects of notification emission.</li>
</ul>
<t>All common semantic fields defined in Section 8.1 apply.</t>
</section>

<section anchor="anydata-and-anyxml"><name><tt>anydata</tt> and <tt>anyxml</tt></name>
<t>A node object with <tt>node-type</tt> value <tt>&quot;anydata&quot;</tt> represents a YANG 1.1
anydata node [RFC7950].  An anydata node models an unknown set of
YANG-modeled data nodes whose structure is not specified at design time.</t>
<t>A node object with <tt>node-type</tt> value <tt>&quot;anyxml&quot;</tt> represents a YANG
anyxml node.  An anyxml node models an opaque XML subtree whose
content is not constrained by a YANG schema.</t>
<t>REQUIRED fields (both types):</t>

<ul spacing="compact">
<li><tt>node-type</tt></li>
<li><tt>path</tt></li>
<li><tt>description</tt></li>
<li><tt>writable</tt>: A boolean.</li>
</ul>
<t>OPTIONAL fields:</t>
<t>All common semantic fields defined in Section 8.1 apply.</t>
<t>Note: The presence of any <tt>anydata</tt> node in a NAIM Document triggers
automatic upgrade to YANG 1.1 output (see Section 15.3.3).  <tt>anyxml</tt>
nodes do not trigger this upgrade, as <tt>anyxml</tt> is available in both
YANG 1.0 and YANG 1.1.</t>
</section>

<section anchor="node-ordering"><name>Node Ordering</name>
<t>In YANG, the order of schema nodes in a module definition has no
semantic meaning [RFC7950].  Accordingly, this document does not define a
required ordering of node objects within the <tt>nodes</tt> array.
Implementations MUST NOT assign semantic meaning to the position of a
node object within the array.</t>
<t>For deterministic output, implementations SHOULD produce canonical JSON
and Markdown Views using a consistent, documented traversal strategy.
Depth-first traversal ordered by <tt>path</tt> value is RECOMMENDED.</t>
</section>
</section>

<section anchor="top-level-array-entry-schemas"><name>Top-Level Array Entry Schemas</name>

<section anchor="typedef"><name><tt>typedef</tt></name>
<t>A typedef entry in the <tt>typedefs</tt> array defines a reusable named type.
Each typedef object MUST contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: A string.  The typedef name.</li>
<li><tt>description</tt>: A string.</li>
<li><tt>base-type</tt>: A string identifying the built-in or derived type on
which this typedef is based.</li>
</ul>
<t>Each typedef object MAY contain:</t>

<ul spacing="compact">
<li><tt>range</tt>: A string expressing a numeric range constraint.</li>
<li><tt>length</tt>: A string expressing a string length constraint.</li>
<li><tt>pattern</tt>: A string expressing a regular expression constraint.</li>
<li><tt>units</tt>: A string identifying a unit of measurement.</li>
<li><tt>default</tt>: A string expressing a default value.</li>
</ul>
</section>

<section anchor="grouping"><name><tt>grouping</tt></name>
<t>A grouping entry in the <tt>groupings</tt> array defines a reusable structural
fragment.  Each grouping object MUST contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: A string.  The grouping name.</li>
<li><tt>description</tt>: A string.</li>
<li><tt>contains</tt>: An array of absolute schema paths identifying the nodes
that constitute this grouping.</li>
</ul>
</section>

<section anchor="identity"><name><tt>identity</tt></name>
<t>An identity entry in the <tt>identities</tt> array defines a YANG identity.
Each identity object MUST contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: A string.  The identity name.</li>
<li><tt>description</tt>: A string.</li>
</ul>
<t>Each identity object MAY contain:</t>

<ul spacing="compact">
<li><tt>base</tt>: A string identifying the base identity.  It MAY use a
module-prefixed form such as <tt>&quot;module-name:identity-name&quot;</tt>.</li>
<li><tt>status</tt>: A string.  If present, it MUST be one of <tt>&quot;current&quot;</tt>,
<tt>&quot;deprecated&quot;</tt>, or <tt>&quot;obsolete&quot;</tt>.</li>
<li><tt>reference</tt>: A string.</li>
</ul>
</section>

<section anchor="extension-definition"><name><tt>extension</tt> Definition</name>
<t>An extension entry in the <tt>extensions</tt> array defines an extension
keyword.  Each extension object MUST contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: A string.  The extension keyword name.</li>
<li><tt>description</tt>: A string.</li>
</ul>
<t>Each extension object MAY contain:</t>

<ul spacing="compact">
<li><tt>argument</tt>: A string identifying the argument name if the extension
takes an argument.</li>
<li><tt>reference</tt>: A string citing the specification that defines the
extension.</li>
</ul>
</section>
</section>

<section anchor="type-representation"><name>Type Representation</name>
<t>All <tt>leaf</tt> and <tt>leaf-list</tt> nodes MUST carry a <tt>type</tt> field.  The <tt>type</tt>
field MUST be a JSON object containing at minimum a <tt>base</tt> field that
identifies the type.</t>

<section anchor="simple-types-and-constraints"><name>Simple Types and Constraints</name>
<t>For YANG built-in scalar types (<tt>string</tt>, <tt>boolean</tt>, <tt>uint8</tt>, <tt>uint16</tt>,
<tt>uint32</tt>, <tt>uint64</tt>, <tt>int8</tt>, <tt>int16</tt>, <tt>int32</tt>, <tt>int64</tt>, <tt>decimal64</tt>,
<tt>empty</tt>), the <tt>type</tt> object MUST contain:</t>

<ul spacing="compact">
<li><tt>base</tt>: A string identifying the built-in type name.</li>
</ul>
<t>The <tt>type</tt> object MAY contain the following constraint fields, expressed
as strings using the same syntax as the corresponding YANG statement:</t>

<ul spacing="compact">
<li><tt>range</tt>: Applicable to numeric types.  Example: <tt>&quot;1..65535&quot;</tt>.</li>
<li><tt>length</tt>: Applicable to <tt>string</tt>.  Example: <tt>&quot;1..64&quot;</tt>.</li>
<li><tt>pattern</tt>: Applicable to <tt>string</tt>.  A regular expression.  Multiple
patterns MAY be expressed as an array of strings.</li>
<li><tt>default</tt>: A string expressing the default value.</li>
<li><tt>units</tt>: A string identifying the unit of measurement.</li>
</ul>
<t>Constraint fields SHOULD only be included when they are semantically
applicable to the declared base type.  In particular, <tt>range</tt>, <tt>length</tt>,
and <tt>pattern</tt> have no meaning for <tt>boolean</tt> and <tt>empty</tt> types and MUST
NOT be included for those types.</t>
</section>

<section anchor="enumeration"><name>Enumeration</name>
<t>For <tt>enumeration</tt> types, the <tt>type</tt> object MUST contain:</t>

<ul spacing="compact">
<li><tt>base</tt>: The string <tt>&quot;enumeration&quot;</tt>.</li>
<li><tt>enum</tt>: An array of enumeration entries.</li>
</ul>
<t>Each entry in the <tt>enum</tt> array MAY be either:</t>

<ul spacing="compact">
<li>A string (short form), in which case the implementation MAY assign
integer values sequentially starting from zero, or</li>
<li>An object containing <tt>name</tt> (string, REQUIRED) and <tt>value</tt> (integer,
OPTIONAL).</li>
</ul>
<t>Implementations that require stable enumeration value mappings SHOULD
use the object form with explicit <tt>value</tt> fields.</t>
</section>

<section anchor="bits"><name>Bits</name>
<t>For <tt>bits</tt> types, the <tt>type</tt> object MUST contain:</t>

<ul spacing="compact">
<li><tt>base</tt>: The string <tt>&quot;bits&quot;</tt>.</li>
<li><tt>bits</tt>: An array of bit entries.</li>
</ul>
<t>Each entry in the <tt>bits</tt> array SHOULD contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: A string.  The bit name.</li>
<li><tt>position</tt>: An integer.  The bit position.  If absent, the
implementation MAY assign positions sequentially starting from zero.</li>
</ul>
</section>

<section anchor="union"><name>Union</name>
<t>For <tt>union</tt> types, the <tt>type</tt> object MUST contain:</t>

<ul spacing="compact">
<li><tt>base</tt>: The string <tt>&quot;union&quot;</tt>.</li>
<li><tt>types</tt>: An array of type objects, each conforming to this section.</li>
</ul>
</section>

<section anchor="leafref"><name>Leafref</name>
<t>For <tt>leafref</tt> types, the <tt>type</tt> object MUST contain:</t>

<ul spacing="compact">
<li><tt>base</tt>: The string <tt>&quot;leafref&quot;</tt>.</li>
<li><tt>path</tt>: A string giving the absolute schema path of the referenced
leaf, following the path conventions in Section 5.6.</li>
</ul>
<t>The <tt>type</tt> object MAY contain:</t>

<ul spacing="compact">
<li><tt>require-instance</tt>: A boolean.  Corresponds to the YANG
<tt>require-instance</tt> statement.  Defaults to <tt>true</tt> if absent.</li>
</ul>
</section>

<section anchor="identityref"><name>Identityref</name>
<t>For <tt>identityref</tt> types, the <tt>type</tt> object MUST contain:</t>

<ul spacing="compact">
<li><tt>base</tt>: The string <tt>&quot;identityref&quot;</tt>.</li>
<li><tt>identity</tt>: A string identifying the base identity.  It MAY use a
module-prefixed form.</li>
</ul>
</section>

<section anchor="typedef-reference"><name>Typedef Reference</name>
<t>When a node's type is a previously defined typedef rather than a
built-in type, the <tt>type</tt> object MUST contain:</t>

<ul spacing="compact">
<li><tt>base</tt>: A string giving the typedef name.</li>
</ul>
<t>The implementation is responsible for resolving the typedef name against
the <tt>typedefs</tt> array of the same NAIM Document or against known external
type definitions.</t>
<t>When resolving the <tt>base</tt> field, an implementation MUST first check
whether the value matches an entry in the <tt>typedefs</tt> array of the same
NAIM Document.  If a match is found, the type is treated as a typedef
reference.  If no match is found, the value is interpreted as a YANG
built-in type name.  Typedef names SHOULD NOT duplicate YANG built-in
type names to avoid ambiguity.</t>
</section>
</section>

<section anchor="visibility-fields"><name>Visibility Fields</name>
<t>The <tt>visibility</tt> field of a node object expresses the conditions under
which the node is present or applicable.  This field corresponds to the
YANG <tt>if-feature</tt> and <tt>when</tt> constructs.</t>

<section anchor="if-feature"><name><tt>if-feature</tt></name>
<t>The <tt>if-feature</tt> field within a <tt>visibility</tt> object declares that the
node is conditional on one or more features.</t>
<t>The <tt>if-feature</tt> value MAY be:</t>

<ul spacing="compact">
<li>A simple string naming a single feature, or</li>
<li>A logical expression object using <tt>and</tt>, <tt>or</tt>, or <tt>not</tt> keys.  <tt>and</tt>
and <tt>or</tt> values are arrays of feature names or nested logical
expression objects.  <tt>not</tt> value is a single feature name or nested
logical expression object.</li>
</ul>
<t>Examples:</t>

<ul spacing="compact">
<li>Single feature: <tt>{ &quot;if-feature&quot;: &quot;high-speed&quot; }</tt></li>
<li>Conjunction: <tt>{ &quot;if-feature&quot;: { &quot;and&quot;: [&quot;feature-a&quot;, &quot;feature-b&quot;] } }</tt></li>
<li>Nested: <tt>{ &quot;if-feature&quot;: { &quot;or&quot;: [&quot;feature-a&quot;, { &quot;and&quot;: [&quot;feature-b&quot;, &quot;feature-c&quot;] }] } }</tt></li>
<li>Negation: <tt>{ &quot;if-feature&quot;: { &quot;not&quot;: &quot;feature-a&quot; } }</tt></li>
</ul>
</section>

<section anchor="when"><name><tt>when</tt></name>
<t>The <tt>when</tt> field within a <tt>visibility</tt> object declares a conditional
expression that must evaluate to true for the node to be present.</t>
<t>The <tt>when</tt> value MAY be:</t>

<ul spacing="compact">
<li>A natural-language string describing the condition, or</li>
<li><t>An object containing:</t>

<ul spacing="compact">
<li><tt>xpath</tt> (string, REQUIRED in this form): An XPath expression.</li>
<li><tt>description</tt> (string, OPTIONAL): A human-readable description of
the condition.</li>
</ul></li>
</ul>
<t>When <tt>when</tt> is expressed as a natural-language string, implementations
SHOULD attempt to derive an equivalent XPath expression during YANG
generation.  If a reliable XPath expression cannot be derived, the
implementation MUST NOT silently discard the condition.  The
implementation SHOULD either report that the condition requires manual
completion or retain the natural-language form in the generated YANG
<tt>description</tt> statement with a clear annotation that XPath completion is
pending.</t>
</section>
</section>

<section anchor="deviation-declarations"><name>Deviation Declarations</name>
<t>Deviation declarations describe the ways in which a specific device
implementation departs from a base YANG module.  They correspond to the
YANG <tt>deviation</tt> statement.</t>
<t>Deviation objects MAY appear in the <tt>deviations</tt> field of the <tt>module</tt>
object defined in Section 5.3.</t>
<t>Each deviation object MUST contain:</t>

<ul spacing="compact">
<li><tt>target</tt>: A string.  The absolute schema path of the node being
deviated.</li>
<li><tt>type</tt>: A string.  It MUST be one of <tt>&quot;not-supported&quot;</tt>, <tt>&quot;add&quot;</tt>,
<tt>&quot;replace&quot;</tt>, or <tt>&quot;delete&quot;</tt>.</li>
<li><tt>reason</tt>: A string.  A human-readable explanation of why this
deviation exists.</li>
</ul>
<t>Deviation objects of type <tt>&quot;add&quot;</tt>, <tt>&quot;replace&quot;</tt>, or <tt>&quot;delete&quot;</tt> MAY
contain additional fields describing the specific property being added,
replaced, or deleted, using the same field names as the corresponding
node template fields.</t>
</section>

<section anchor="extension-use"><name>Extension Use</name>
<t>Extension use within a node object allows a node to carry annotations
defined by extension declarations in the <tt>extensions</tt> array or by
external modules.</t>
<t>When present, the <tt>extensions</tt> field of a node object MUST be an array.
Each entry MUST contain:</t>

<ul spacing="compact">
<li><tt>name</tt>: A string.  The qualified extension keyword, typically in the
form <tt>&quot;prefix:keyword&quot;</tt>.</li>
<li><tt>source-module</tt>: A string.  The name of the YANG module that defines
the extension.</li>
<li><tt>meaning</tt>: A string.  A human-readable description of why this
extension is applied to this node and what it semantically conveys.</li>
</ul>
<t>Each entry MAY contain:</t>

<ul spacing="compact">
<li><tt>value</tt>: A string.  The literal argument value passed to the
extension.</li>
</ul>
<t>If any of the required fields above cannot be determined, the
implementation MUST omit the extension-use entry entirely rather than
emit an incomplete representation.  The implementation SHOULD inform the
user or operator that the extension entry was omitted and that manual
completion may be required.</t>
</section>

<section anchor="submodule-handling"><name>Submodule Handling</name>
<t>A NAIM Document representing a YANG submodule MUST contain a <tt>submodule</tt>
object at the top level instead of a <tt>module</tt> object, as specified in
Section 5.4.</t>
<t>A submodule NAIM Document MAY contain <tt>typedefs</tt>, <tt>groupings</tt>,
<tt>identities</tt>, <tt>extensions</tt>, <tt>features</tt>, and <tt>nodes</tt> arrays.</t>
<t>When a conforming implementation transforms a submodule NAIM Document
into YANG, the result MUST:</t>

<ul spacing="compact">
<li>include a <tt>belongs-to</tt> statement referencing the parent module name
given in the <tt>belongs-to</tt> field of the <tt>submodule</tt> object;</li>
<li>include a <tt>prefix</tt> sub-statement within <tt>belongs-to</tt>, as required by
[RFC7950, Section 7.2.2] -- the prefix value is derived using the
same automatic derivation rule defined in Section 15.3.2;</li>
<li>NOT include a <tt>namespace</tt> statement, as the namespace is inherited
from the parent module; and</li>
<li>NOT include a module-level <tt>prefix</tt> statement for the same reason.</li>
</ul>
</section>

<section anchor="naim-skills"><name>NAIM Skills</name>
<t>This section defines four Skills that constitute the Skill Layer of the
NAIM architecture.  Each Skill specifies inputs, outputs, and behavioral
rules for AI participation in the modeling workflow.</t>
<t>Skills are independently versionable and customizable: implementations
MAY adapt question strategies, presentation styles, and interaction
patterns to their target user populations without violating the
normative requirements of this section.</t>

<section anchor="skill-a-conversational-modeling"><name>Skill A: Conversational Modeling</name>
<t>Skill A transforms natural language modeling intent into a complete NAIM
Document through structured dialogue.</t>
<t><strong>Input</strong>: Natural language description of a network resource, or an
existing NAIM Document with incremental modeling requirements.</t>
<t><strong>Output</strong>: A complete NAIM Document in Canonical JSON.</t>

<section anchor="behavioral-requirements"><name>Behavioral Requirements</name>
<t>Skill A MUST:</t>

<ul spacing="compact">
<li>when the user expresses modeling intent, first determine whether this
is a new model or a continuation of an existing model;</li>
<li>generate an initial draft, marking uncertain fields with <tt>[PENDING]</tt>;</li>
<li>identify missing required fields and prompt for clarification;</li>
<li>ask one question at a time;</li>
<li>prioritize structural questions before type and constraint questions;</li>
<li>identify opportunities for typedef and grouping abstraction when
repeated types or structures are detected;</li>
<li>not proceed to Skill B until the document meets the completeness
criteria defined in Section 15.1.2.</li>
</ul>
</section>

<section anchor="completeness-criteria"><name>Completeness Criteria</name>
<t>A NAIM Document is considered complete for the purposes of Skill A when:</t>

<ul spacing="compact">
<li>all nodes have <tt>path</tt>, <tt>description</tt>, and <tt>node-type</tt>;</li>
<li>all <tt>list</tt> nodes have <tt>key</tt>;</li>
<li>all <tt>leaf</tt> and <tt>leaf-list</tt> nodes have <tt>type</tt> and <tt>writable</tt>;</li>
<li>all <tt>choice</tt> nodes have a non-empty <tt>cases</tt> array;</li>
<li>each case has <tt>name</tt> and <tt>nodes</tt>;</li>
<li>all <tt>container</tt> and <tt>list</tt> nodes have <tt>operations.preconditions</tt> and
<tt>operations.side-effects</tt>; and</li>
<li>no <tt>[PENDING]</tt> markers remain.</li>
</ul>
</section>

<section anchor="recommended-question-priority"><name>Recommended Question Priority</name>

<ol spacing="compact">
<li>Node type and hierarchy structure</li>
<li>Writable (configuration vs. state)</li>
<li>Type and value constraints</li>
<li>Related nodes</li>
<li>Preconditions and side effects</li>
<li>Visibility conditions</li>
<li>Extension keywords and additional semantics</li>
</ol>
</section>
</section>

<section anchor="skill-b-natural-language-summarization"><name>Skill B: Natural Language Summarization</name>
<t>Skill B transforms a complete NAIM Document into a natural language
summary for human confirmation before proceeding to generation.</t>
<t><strong>Input</strong>: A complete NAIM Document in Canonical JSON.</t>
<t><strong>Output</strong>: A natural language summary.</t>

<section anchor="output-requirements"><name>Output Requirements</name>
<t>The summary MUST:</t>

<ul spacing="compact">
<li>not expose internal NAIM syntax or JSON structure;</li>
<li>organize content by business function, not by field enumeration;</li>
<li>distinguish configurable items from read-only items;</li>
<li>describe key constraints and side effects;</li>
<li>provide separate descriptions for rpc, action, and notification nodes;
and</li>
<li>conclude with an explicit request for user confirmation.</li>
</ul>
</section>
</section>

<section anchor="skill-c-yang-generation"><name>Skill C: YANG Generation</name>
<t>Skill C transforms a confirmed NAIM Document into a standard YANG
module through deterministic tooling.</t>
<t><strong>Input</strong>: A confirmed NAIM Document in Canonical JSON.</t>
<t><strong>Output</strong>: A YANG module conforming to [RFC7950] or [RFC6020].</t>

<section anchor="core-mapping-rules"><name>Core Mapping Rules</name>

<ul spacing="compact">
<li><tt>path</tt> determines the node's position in the schema tree;</li>
<li><tt>description</tt> maps to YANG <tt>description</tt>;</li>
<li><tt>writable: false</tt> maps to <tt>config false</tt>;</li>
<li><tt>type</tt> is generated per the type representation rules in Section 10;</li>
<li>natural-language <tt>constraints</tt> and <tt>when</tt> SHOULD be converted to
XPath where possible; if conversion is not reliable, the
implementation MUST report the issue rather than silently discard the
constraint;</li>
<li>cross-module paths automatically generate <tt>import</tt> statements;</li>
<li><tt>if-feature</tt> logical expressions are converted to valid YANG
<tt>if-feature</tt> statements; and</li>
<li>all top-level arrays (<tt>features</tt>, <tt>typedefs</tt>, <tt>groupings</tt>,
<tt>identities</tt>, <tt>extensions</tt>, <tt>deviations</tt>, <tt>revisions</tt>) map to their
corresponding YANG statements.</li>
</ul>
</section>

<section anchor="prefix-and-namespace-generation"><name>Prefix and Namespace Generation</name>

<ul spacing="compact">
<li>YANG <tt>prefix</tt> MAY be derived automatically from the module name (e.g.,
taking the first letter of each hyphen-separated segment).  The same
derivation rule applies to the <tt>prefix</tt> sub-statement within
<tt>belongs-to</tt> for submodule generation (see Section 14).</li>
<li><t><tt>namespace</tt> is generated from a template:</t>

<ul spacing="compact">
<li>IETF-style modules: <tt>urn:ietf:params:xml:ns:yang:{module-name}</tt></li>
<li>Private modules: organization-specific template, e.g.,
<tt>urn:example:{module-name}</tt></li>
</ul></li>
</ul>
</section>

<section anchor="yang-version-strategy"><name>YANG Version Strategy</name>
<t>Unless the NAIM Document explicitly models YANG 1.1-only semantics,
Skill C MUST default to generating YANG 1.0 <eref target="i.e.,
`yang-version 1;` or version statement omitted">RFC6020</eref>.</t>
<t>Skill C SHOULD automatically upgrade to YANG 1.1 <eref target="i.e.,
`yang-version 1.1;`">RFC7950</eref> when the NAIM Document contains any of the
following:</t>
<table>
<thead>
<tr>
<th>YANG 1.1-only feature</th>
<th>NAIM modeling indicator</th>
</tr>
</thead>

<tbody>
<tr>
<td><tt>action</tt> node</td>
<td><tt>node-type</tt> is <tt>&quot;action&quot;</tt> (distinct from top-level <tt>rpc</tt>)</td>
</tr>

<tr>
<td><tt>anydata</tt></td>
<td><tt>node-type</tt> is <tt>&quot;anydata&quot;</tt> (see Section 8.7)</td>
</tr>

<tr>
<td><tt>if-feature</tt> logical expression</td>
<td><tt>visibility.if-feature</tt> uses <tt>and</tt>/<tt>or</tt>/<tt>not</tt> compound objects</td>
</tr>

<tr>
<td><tt>modifier</tt> (invert-match)</td>
<td><tt>type.pattern</tt> includes negation semantics</td>
</tr>

<tr>
<td><tt>augment</tt> with <tt>when</tt></td>
<td>A node whose <tt>path</tt> targets another module's namespace (cross-module augmentation) and whose <tt>visibility.when</tt> is present</td>
</tr>
</tbody>
</table><t>If a YANG 1.1-only feature is detected but the target environment is
explicitly constrained to YANG 1.0, the implementation MUST report the
incompatibility rather than silently downgrade or skip the affected
nodes.</t>
</section>

<section anchor="submodule-generation"><name>Submodule Generation</name>
<t>When the input is a <tt>submodule</tt>-type NAIM Document, the YANG generation
rules defined in Section 14 apply.</t>
</section>
</section>

<section anchor="skill-d-reverse-engineering"><name>Skill D: Reverse Engineering</name>
<t>Skill D transforms existing YANG modules into NAIM Documents, enriching
them with AI-generated semantic annotations.</t>
<t><strong>Input</strong>: An existing YANG module.</t>
<t><strong>Output</strong>: A NAIM Document in Canonical JSON with confidence
annotations.</t>

<section anchor="dual-component-architecture"><name>Dual-Component Architecture</name>
<t>Skill D is implemented as two complementary components:</t>
<t><strong>Structural extraction (Tool Layer)</strong>: Deterministic extraction of
YANG-derivable fields at high confidence:</t>

<ul spacing="compact">
<li>node-type, path, key, config/writable status</li>
<li>type (including range, length, pattern, enum, bits)</li>
<li>default values, must/when expressions, if-feature</li>
<li>typedef, grouping, rpc/action/notification structure</li>
</ul>
<t><strong>Semantic completion (AI)</strong>: AI-assisted enrichment of fields not
directly present in YANG syntax:</t>

<ul spacing="compact">
<li>enhanced natural language descriptions</li>
<li>relationship explanations</li>
<li>operational semantics (preconditions, side-effects)</li>
<li>usage examples</li>
</ul>
</section>

<section anchor="confidence-levels"><name>Confidence Levels</name>
<t>All AI-generated fields in Skill D output MUST carry confidence
annotations:</t>

<ul spacing="compact">
<li><strong>high</strong>: Directly derived from YANG structure; no AI inference.</li>
<li><strong>medium</strong>: Derived from YANG <tt>description</tt> statements or referenced
RFC text; moderate inference.</li>
<li><strong>review-required</strong>: AI-inferred from context; MUST be reviewed by a
qualified person before production use.</li>
</ul>
</section>

<section anchor="review-requirements"><name>Review Requirements</name>

<ul spacing="compact">
<li>Structurally extracted fields MAY be used without additional review.</li>
<li>AI-generated descriptions, preconditions, side-effects, and
error-conditions with <tt>review-required</tt> confidence MUST NOT be
published to production model assets without human confirmation.</li>
<li>AI-generated regular expressions, XPath expressions, and constraint
expressions MUST be treated as <tt>review-required</tt> regardless of the
AI system's stated confidence.</li>
</ul>
</section>
</section>
</section>

<section anchor="known-limitations"><name>Known Limitations</name>
<t>NAIM improves the reliability of AI-assisted YANG modeling by making
implicit semantics explicit and machine-verifiable.  However, the
following limitations apply:</t>

<ul spacing="compact">
<li>NAIM does not replace expert review for complex XPath expressions,
cross-module constraint interactions, and security implications of
modeled operations.</li>
<li>The quality of Skill A output is bounded by the quality of the
underlying AI system.  NAIM provides structure and guardrails, not
intelligence.</li>
<li>Skill D output at <tt>review-required</tt> confidence MUST NOT be treated as
authoritative.  AI-inferred operational semantics (preconditions,
side-effects) may be plausible but incorrect.</li>
<li>Reliable generation of complex XPath from natural language remains
best-effort.  Implementations MUST report when XPath generation is
uncertain rather than emit incorrect expressions.</li>
<li>NAIM does not model cross-module augmentation relationships, mount
points, or YANG library structures.  These are outside the scope of
the current version.</li>
<li>NAIM does not model YANG <tt>refine</tt> statements within <tt>uses</tt>
applications.</li>
</ul>
</section>

<section anchor="interoperability-expectations"><name>Interoperability Expectations</name>
<t>Interoperability in this specification is defined at the representation
level.  Independent implementations conforming to this document SHOULD
be able to exchange canonical NAIM Document JSON objects and interpret
them consistently.</t>
<t>Specifically, conforming implementations:</t>

<ul spacing="compact">
<li>MUST accept and produce canonical JSON objects that conform to the
top-level structure defined in Section 5.</li>
<li>MUST interpret <tt>node-type</tt> values consistently with the node template
families defined in Section 8.</li>
<li>MUST interpret <tt>type</tt> field contents consistently with the type
representation rules defined in Section 10.</li>
<li>MUST preserve the <tt>path</tt>, <tt>description</tt>, <tt>writable</tt>, and <tt>type</tt> fields
of node objects when exchanging NAIM Documents.</li>
<li>SHOULD preserve all optional semantic fields when exchanging NAIM
Documents, even if the receiving implementation does not use those
fields internally.</li>
<li>MUST NOT reject NAIM Documents solely because they contain fields that
the implementation does not recognize.  Unknown fields SHOULD be
preserved and forwarded without modification.</li>
<li>SHOULD produce Markdown Views that conform to the rendering rules in
Section 6 when a Markdown View is requested.</li>
<li>SHOULD produce LLM Context Views that conform to the requirements in
Section 7 when an LLM Context View is requested.</li>
</ul>
<t>Implementations are NOT required to share identical AI interaction
logic, reconstruction algorithms, confidence handling strategies, or
YANG generation internals.  Interoperability is defined at the data
format boundary, not at the workflow boundary.</t>
<t>Implementations SHOULD clearly distinguish between NAIM-level
validation (structural conformance to this specification) and
YANG-level validation (semantic conformance to YANG rules and target
device constraints).  A NAIM Document that conforms to the schema
defined in Appendix A is structurally valid but is not guaranteed to
produce a YANG module that will pass validation in any specific
YANG-based system.  Authoritative semantic validation -- including
evaluation of YANG <tt>must</tt>, <tt>when</tt>, and <tt>leafref</tt> expressions,
uniqueness constraints, and instance-level data validation -- is the
responsibility of the target YANG validation environment, not of NAIM
tools (see Section 1.3).</t>
</section>

<section anchor="security-considerations"><name>Security Considerations</name>
<t>NAIM Documents are semantic model artifacts.  They do not themselves
constitute executable code or protocol messages, but they may drive
downstream processes -- including YANG module generation and, through
[NAIM-OP], runtime network configuration -- that have direct operational
consequences.  The following security considerations apply.</t>
<t><strong>Integrity of NAIM Documents.</strong>  Because a NAIM Document may be used as
input to deterministic tool pipelines that generate YANG modules or as
the validation authority for runtime Operation IRs [NAIM-OP],
unauthorized modification of a NAIM Document can introduce incorrect or
malicious semantics into downstream artifacts.  Implementations SHOULD
protect NAIM Documents in storage and transit using integrity mechanisms
appropriate to the deployment environment.</t>
<t><strong>Confidentiality of semantic model assets.</strong>  NAIM Documents may
contain detailed descriptions of network topology, device capabilities,
and operational constraints.  This information may be sensitive.
Implementations SHOULD apply confidentiality protections appropriate to
the sensitivity of the modeled information.</t>
<t><strong>Validation before downstream use.</strong>  Implementations that consume NAIM
Documents as input to YANG generation or runtime validation MUST
validate the structural conformance of the document before processing.
Accepting malformed or adversarially crafted NAIM Documents without
validation may produce incorrect YANG modules or permit invalid
Operation IRs to pass validation.</t>
<t><strong>AI-generated content review.</strong>  When a NAIM Document is produced in
whole or in part by an AI-assisted authoring process (Skills A and D),
the resulting document SHOULD be subject to human review before it is
used to generate or deploy production YANG modules or serve as a runtime
validation authority.  AI-generated semantic content may contain
inaccuracies that are not apparent from structural validation alone.</t>
<t><strong>External document integrity.</strong>  If Skill D retrieves external
documents (RFCs, vendor documentation) during reverse engineering,
implementations SHOULD verify the authenticity and integrity of those
documents to prevent contamination of the modeling result.</t>
<t><strong>Audit logging.</strong>  Implementations that participate in workflows where
NAIM Documents drive operational changes SHOULD maintain audit logs
sufficient to reconstruct the chain of actions from a NAIM Document to a
resulting downstream state change.  Skill A dialogue logs and
intermediate JSON artifacts may contain sensitive network information
and SHOULD be subject to access control and retention policies.</t>
</section>

<section anchor="iana-considerations"><name>IANA Considerations</name>
<t>This document has no IANA actions.</t>
<t>Future companion documents defining a media type for the NAIM canonical
JSON format MAY request registration of an appropriate media type with
IANA at that time.</t>
</section>

<section anchor="references"><name>References</name>

<section anchor="normative-references"><name>Normative References</name>

<sourcecode type="text"><![CDATA[[RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
           Requirement Levels", BCP 14, RFC 2119,
           DOI 10.17487/RFC2119, March 1997,
           <https://www.rfc-editor.org/rfc/rfc2119>.

[RFC6020]  Bjorklund, M., Ed., "YANG - A Data Modeling Language for
           the Network Configuration Protocol (NETCONF)", RFC 6020,
           DOI 10.17487/RFC6020, October 2010,
           <https://www.rfc-editor.org/rfc/rfc6020>.

[RFC6901]  Bryan, P., Ed., Zyp, K., and M. Nottingham, Ed.,
           "JavaScript Object Notation (JSON) Pointer", RFC 6901,
           DOI 10.17487/RFC6901, April 2013,
           <https://www.rfc-editor.org/rfc/rfc6901>.

[RFC7950]  Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language",
           RFC 7950, DOI 10.17487/RFC7950, August 2016,
           <https://www.rfc-editor.org/rfc/rfc7950>.

[RFC8174]  Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
           2119 Key Words", BCP 14, RFC 8174,
           DOI 10.17487/RFC8174, May 2017,
           <https://www.rfc-editor.org/rfc/rfc8174>.

[RFC8259]  Bray, T., Ed., "The JavaScript Object Notation (JSON)
           Data Interchange Format", STD 90, RFC 8259,
           DOI 10.17487/RFC8259, December 2017,
           <https://www.rfc-editor.org/rfc/rfc8259>.
]]></sourcecode>
</section>

<section anchor="informative-references"><name>Informative References</name>

<sourcecode type="text"><![CDATA[[RFC6241]  Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed.,
           and A. Bierman, Ed., "Network Configuration Protocol
           (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011,
           <https://www.rfc-editor.org/rfc/rfc6241>.

[RFC8040]  Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF
           Protocol", RFC 8040, DOI 10.17487/RFC8040, January 2017,
           <https://www.rfc-editor.org/rfc/rfc8040>.

[RFC8340]  Bjorklund, M. and L. Berger, Ed., "YANG Tree Diagrams",
           BCP 215, RFC 8340, DOI 10.17487/RFC8340, March 2018,
           <https://www.rfc-editor.org/rfc/rfc8340>.

[NAIM-OP]  Feng, C., "Operation Intent Intermediate Representation
           for Model-Driven Network Execution", Work in Progress,
           Internet-Draft, draft-feng-netconf-naim-op-00, April 2026.
]]></sourcecode>
</section>
</section>

<section anchor="naim-canonical-json-schema"><name>NAIM Canonical JSON Schema</name>
<t>The following is the normative JSON Schema for NAIM Documents.
Implementations that validate NAIM Documents MUST accept documents
conforming to this schema.</t>

<sourcecode type="json"><![CDATA[{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["version"],
  "oneOf": [
    { "required": ["module"] },
    { "required": ["submodule"] }
  ],
  "properties": {
    "version": { "type": "string", "const": "1.0" },
    "module": {
      "type": "object",
      "required": ["name", "description"],
      "properties": {
        "name": { "type": "string" },
        "description": { "type": "string" },
        "organization": { "type": "string" },
        "contact": { "type": "string" },
        "reference": { "type": "string" },
        "deviations": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["target", "type", "reason"],
            "properties": {
              "target": { "type": "string" },
              "type": {
                "enum": ["not-supported", "add", "replace", "delete"]
              },
              "reason": { "type": "string" }
            }
          }
        }
      }
    },
    "submodule": {
      "type": "object",
      "required": ["name", "belongs-to"],
      "properties": {
        "name": { "type": "string" },
        "belongs-to": { "type": "string" },
        "description": { "type": "string" }
      }
    },
    "revisions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["revision", "description"],
        "properties": {
          "revision": { "type": "string", "format": "date" },
          "description": { "type": "string" },
          "reference": { "type": "string" }
        }
      }
    },
    "features": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "description"],
        "properties": {
          "name": { "type": "string" },
          "description": { "type": "string" },
          "status": {
            "enum": ["current", "deprecated", "obsolete"]
          },
          "reference": { "type": "string" }
        }
      }
    },
    "typedefs": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "description", "base-type"],
        "properties": {
          "name": { "type": "string" },
          "description": { "type": "string" },
          "base-type": { "type": "string" },
          "range": { "type": "string" },
          "length": { "type": "string" },
          "pattern": { "type": "string" },
          "units": { "type": "string" },
          "default": { "type": "string" }
        }
      }
    },
    "groupings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "description", "contains"],
        "properties": {
          "name": { "type": "string" },
          "description": { "type": "string" },
          "contains": {
            "type": "array",
            "items": { "type": "string" }
          }
        }
      }
    },
    "identities": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "description"],
        "properties": {
          "name": { "type": "string" },
          "description": { "type": "string" },
          "base": { "type": "string" },
          "status": {
            "enum": ["current", "deprecated", "obsolete"]
          },
          "reference": { "type": "string" }
        }
      }
    },
    "extensions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "description"],
        "properties": {
          "name": { "type": "string" },
          "description": { "type": "string" },
          "argument": { "type": "string" },
          "reference": { "type": "string" }
        }
      }
    },
    "nodes": {
      "type": "array",
      "items": { "$ref": "#/definitions/nodeObject" }
    }
  },
  "definitions": {
    "nodeObject": {
      "type": "object",
      "required": ["node-type", "path", "description"],
      "properties": {
        "node-type": {
          "enum": ["leaf", "leaf-list", "container", "list",
                   "choice", "rpc", "action", "notification",
                   "anydata", "anyxml"]
        },
        "path": { "type": "string" },
        "description": { "type": "string" },
        "writable": { "type": "boolean" },
        "key": { "type": "string" },
        "type": { "$ref": "#/definitions/typeSpec" },
        "uses": { "type": "string" },
        "mandatory": { "type": "boolean" },
        "status": {
          "enum": ["current", "deprecated", "obsolete"]
        },
        "presence": { "type": "string" },
        "min-elements": { "type": "integer", "minimum": 0 },
        "max-elements": {
          "oneOf": [
            { "type": "integer", "minimum": 1 },
            { "type": "string", "const": "unbounded" }
          ]
        },
        "unique": {
          "type": "array",
          "items": { "type": "string" }
        },
        "ordered-by": {
          "enum": ["system", "user"]
        },
        "operations": {
          "type": "object",
          "properties": {
            "preconditions": { "type": "string" },
            "side-effects": { "type": "string" }
          }
        },
        "visibility": {
          "type": "object",
          "properties": {
            "if-feature": {
              "oneOf": [
                { "type": "string" },
                { "type": "object" }
              ]
            },
            "when": {
              "oneOf": [
                { "type": "string" },
                {
                  "type": "object",
                  "required": ["xpath"],
                  "properties": {
                    "xpath": { "type": "string" },
                    "description": { "type": "string" }
                  }
                }
              ]
            }
          }
        },
        "related-nodes": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "path": { "type": "string" },
              "relationship": { "type": "string" }
            }
          }
        },
        "constraints": {
          "oneOf": [
            { "type": "string" },
            {
              "type": "object",
              "required": ["xpath"],
              "properties": {
                "xpath": { "type": "string" },
                "description": { "type": "string" }
              }
            }
          ]
        },
        "examples": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "scenario": { "type": "string" },
              "operation": { "type": "string" }
            }
          }
        },
        "extensions": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["name", "source-module", "meaning"],
            "properties": {
              "name": { "type": "string" },
              "source-module": { "type": "string" },
              "meaning": { "type": "string" },
              "value": { "type": "string" }
            }
          }
        },
        "cases": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["name", "nodes"],
            "properties": {
              "name": { "type": "string" },
              "description": { "type": "string" },
              "nodes": {
                "type": "array",
                "items": { "type": "string" }
              }
            }
          }
        },
        "input": { "type": "string" },
        "output": { "type": "string" },
        "preconditions": { "type": "string" },
        "side-effects": { "type": "string" },
        "error-conditions": { "type": "string" },
        "trigger": { "type": "string" },
        "data": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": { "type": "string" },
              "type": { "type": "string" },
              "description": { "type": "string" }
            }
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "node-type": { "enum": ["leaf", "leaf-list"] }
            }
          },
          "then": {
            "required": ["type", "writable"]
          }
        },
        {
          "if": {
            "properties": {
              "node-type": { "const": "container" }
            }
          },
          "then": {
            "required": ["writable"]
          }
        },
        {
          "if": {
            "properties": {
              "node-type": { "const": "list" }
            }
          },
          "then": {
            "required": ["writable"]
          }
        },
        {
          "if": {
            "properties": {
              "node-type": { "const": "list" },
              "writable": { "const": true }
            },
            "required": ["writable"]
          },
          "then": {
            "required": ["key"]
          }
        },
        {
          "if": {
            "properties": {
              "node-type": { "const": "choice" }
            }
          },
          "then": {
            "required": ["cases"]
          }
        },
        {
          "if": {
            "properties": {
              "node-type": { "enum": ["anydata", "anyxml"] }
            }
          },
          "then": {
            "required": ["writable"]
          }
        }
      ]
    },
    "typeSpec": {
      "type": "object",
      "required": ["base"],
      "properties": {
        "base": { "type": "string" },
        "range": { "type": "string" },
        "length": { "type": "string" },
        "pattern": {
          "oneOf": [
            { "type": "string" },
            { "type": "array", "items": { "type": "string" } }
          ]
        },
        "default": { "type": "string" },
        "units": { "type": "string" },
        "enum": {
          "oneOf": [
            {
              "type": "array",
              "items": { "type": "string" }
            },
            {
              "type": "array",
              "items": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": { "type": "string" },
                  "value": { "type": "integer" }
                }
              }
            }
          ]
        },
        "bits": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["name"],
            "properties": {
              "name": { "type": "string" },
              "position": { "type": "integer" }
            }
          }
        },
        "types": {
          "type": "array",
          "items": { "$ref": "#/definitions/typeSpec" }
        },
        "path": { "type": "string" },
        "require-instance": { "type": "boolean" },
        "identity": { "type": "string" }
      }
    }
  }
}
]]></sourcecode>
</section>

<section anchor="example-canonical-json-document"><name>Example: Canonical JSON Document</name>
<t>The following is an example of a conforming canonical NAIM Document
representing a simplified Ethernet interface module.</t>

<sourcecode type="json"><![CDATA[{
  "version": "1.0",
  "module": {
    "name": "eth-interface",
    "description": "Ethernet interface config and state",
    "organization": "Example Networks"
  },
  "revisions": [
    {
      "revision": "2026-07-17",
      "description": "Initial version"
    }
  ],
  "features": [
    {
      "name": "high-speed",
      "description": "Support for 10 Gbps or above",
      "status": "current"
    }
  ],
  "typedefs": [
    {
      "name": "bandwidth-mbps",
      "description": "Bandwidth in megabits per second",
      "base-type": "uint32",
      "range": "1..1000000",
      "units": "Mbps"
    }
  ],
  "nodes": [
    {
      "node-type": "container",
      "path": "/eth-interface:interfaces",
      "description": "Top-level container for interfaces",
      "writable": true,
      "operations": {
        "preconditions": "None",
        "side-effects": "None"
      }
    },
    {
      "node-type": "list",
      "path": "/eth-interface:interfaces/interface",
      "description": "An individual Ethernet interface entry",
      "key": "name",
      "writable": true,
      "operations": {
        "preconditions": "Name must be unique.",
        "side-effects": "Allocates HW resources."
      }
    },
    {
      "node-type": "leaf",
      "path": "/eth-interface:interfaces/interface/name",
      "description": "Unique interface name, e.g., eth0.",
      "type": { "base": "string", "length": "1..64" },
      "writable": true
    },
    {
      "node-type": "leaf",
      "path": "/eth-interface:interfaces/interface/bandwidth",
      "description": "Configured bandwidth in Mbps.",
      "type": { "base": "bandwidth-mbps" },
      "writable": true,
      "examples": [
        {
          "scenario": "1 Gbps link",
          "operation": "1000"
        },
        {
          "scenario": "10 Gbps link",
          "operation": "10000"
        }
      ]
    },
    {
      "node-type": "leaf",
      "path": "/eth-interface:interfaces/interface/admin-status",
      "description": "Administrative state of the interface.",
      "type": {
        "base": "enumeration",
        "enum": [
          { "name": "up", "value": 0 },
          { "name": "down", "value": 1 }
        ]
      },
      "writable": true,
      "constraints": "Must be down before deletion.",
      "visibility": {
        "if-feature": "high-speed"
      }
    },
    {
      "node-type": "leaf",
      "path": "/eth-interface:interfaces/interface/oper-status",
      "description": "Operational state of the interface.",
      "type": {
        "base": "enumeration",
        "enum": [
          { "name": "up", "value": 0 },
          { "name": "down", "value": 1 },
          { "name": "testing", "value": 2 }
        ]
      },
      "writable": false
    }
  ]
}
]]></sourcecode>
</section>

<section anchor="example-derived-markdown-view"><name>Example: Derived Markdown View</name>
<t>The following is the Markdown View derived from the canonical JSON
document in Appendix B.</t>

<sourcecode type="markdown"><![CDATA[# module: eth-interface
## description: Ethernet interface config and state

## Revisions
- 2026-07-17: Initial version

## Features
- high-speed: Support for 10 Gbps or above

## Typedefs
- bandwidth-mbps (uint32, range: 1..1000000, Mbps):
  Bandwidth in megabits per second

## Tree
module: eth-interface
  +--rw interfaces
     +--rw interface* [name]
        +--rw name         string
        +--rw bandwidth    bandwidth-mbps
        +--rw admin-status enumeration {high-speed}?
        +--ro oper-status  enumeration

### interfaces (container)
- path: /eth-interface:interfaces
- description: Top-level container for interfaces
- writable: yes
- operations:
  - preconditions: None
  - side-effects: None

### interface (list)
- path: /eth-interface:interfaces/interface
- description: An individual Ethernet interface entry
- key: name
- writable: yes
- operations:
  - preconditions: Name must be unique.
  - side-effects: Allocates HW resources.

### name (leaf)
- path: /eth-interface:interfaces/interface/name
- description: Unique interface name, e.g., eth0.
- type: string (length: 1..64)
- writable: yes

### bandwidth (leaf)
- path: /eth-interface:interfaces/interface/bandwidth
- description: Configured bandwidth in Mbps.
- type: bandwidth-mbps
- writable: yes
- examples:
  - Configure a 1 Gbps interface: 1000
  - Configure a 10 Gbps interface: 10000

### admin-status (leaf)
- path: /eth-interface:interfaces/interface/admin-status
- description: Administrative state of the interface.
- type: enumeration [up(0), down(1)]
- writable: yes
- if-feature: high-speed
- constraints: Must be down before deletion.

### oper-status (leaf)
- path: /eth-interface:interfaces/interface/oper-status
- description: Operational state of the interface.
- type: enumeration [up(0), down(1), testing(2)]
- writable: no
]]></sourcecode>
</section>

<section anchor="end-to-end-example-with-yang-output"><name>End-to-End Example with YANG Output</name>
<t>This appendix presents the YANG module that a conforming implementation
would produce from the canonical JSON document in Appendix B.  Per the
YANG version strategy defined in Section 15.3.3, this example uses
YANG 1.0 because no YANG 1.1-only features are present.</t>
<t>Note: The <tt>admin-status</tt> node in Appendix B carries a natural-language
constraint (&quot;The admin-status MUST be set to 'down' before the
interface can be deleted.&quot;) that cannot be reliably converted into a
YANG XPath expression by deterministic tooling.  Per Section 15.3.1, a
conforming implementation MUST NOT silently discard such a constraint.
In this example, the constraint is retained in the generated YANG
<tt>description</tt> statement with an annotation indicating that manual
completion of a <tt>must</tt> statement is required (see Section 11.2).</t>

<sourcecode type="yang"><![CDATA[module eth-interface {
  yang-version 1;
  namespace "urn:example:eth-interface";
  prefix "eth";

  organization "Example Networks";

  revision 2026-07-17 {
    description "Initial version";
  }

  feature high-speed {
    description
      "Support for 10 Gbps or above";
  }

  typedef bandwidth-mbps {
    type uint32 {
      range "1..1000000";
    }
    units "Mbps";
    description
      "Bandwidth in megabits per second";
  }

  container interfaces {
    description
      "Top-level container for all Ethernet interface configuration";

    list interface {
      key "name";
      description "An individual Ethernet interface entry";

      leaf name {
        type string {
          length "1..64";
        }
        description
          "The unique name of the Ethernet interface,
           such as 'eth0' or 'GigabitEthernet0/1'.";
      }

      leaf bandwidth {
        type bandwidth-mbps;
        description
          "The configured bandwidth of the interface in Mbps.";
      }

      leaf admin-status {
        if-feature "high-speed";
        type enumeration {
          enum up   { value 0; }
          enum down { value 1; }
        }
        description
          "The administrative state of the interface as set by
           the operator.
           NOTE: The NAIM Document contains a natural-language
           constraint ('The admin-status MUST be set to down
           before the interface can be deleted') that could not
           be reliably converted to a YANG XPath expression.
           Manual completion of a 'must' statement is required.";
      }

      leaf oper-status {
        config false;
        type enumeration {
          enum up      { value 0; }
          enum down    { value 1; }
          enum testing { value 2; }
        }
        description
          "The current operational state of the interface
           as observed by the system.";
      }
    }
  }
}
]]></sourcecode>
</section>

</middle>

<back>

</back>

</rfc>
