Skip to content
Edit this page

Config DSL v6: Static Configuration Description Specification

  • Document: config-dsl-02 (Language version 6)
  • Category: Experimental / Specification Draft
  • Chinese edition: 简体中文

Status of This Memo

This document is a repository-level specification draft, not an adopted Wind runtime API or Internet Standard. It specifies the static XML dialect used by the rust-proxy configuration editor as a reference for other configuration editors. The standalone Wind binary does not currently consume this DSL. The draft revision config-dsl-02 and the root attribute version="6" track separate versions.

Sections 1–13 and Section 15 are normative; Section 14 and Appendix A are informative. The Chinese and English editions maintain identical section numbering and normative requirements.

Abstract

Config DSL uses static XML to describe form inputs, defaults, applicability conditions, cross-field rules, fixed transforms, output schemas, and secret redaction. Consumers render forms, validate input, and project structured configurations; TOML, JSON, and YAML are downstream encodings. Descriptions contain no executable code.

1. Scope and Terminology

The key words "MUST", "MUST NOT", "SHOULD", "SHOULD NOT", and "MAY" in this document are to be interpreted as described in BCP 14 (RFC 2119, RFC 8174) when, and only when, they appear in all capitals.

Term Meaning
Description A standalone DSL document independent of any editing session
Consumer An implementation that parses, validates, and projects a description
Host An application providing interactive editing, target validation, and export
Root The object holding top-level input fields and collections
Row The active input object; starts as Root and switches to a collection item during mapping or selection
Projection Structured output generated from a single input snapshot

This DSL does not replace target application parsers or wire protocols. Imports, migrations, includes, arbitrary functions, assignment, recursion, network lookups, and executable expressions are outside version 6. Consumers MUST NOT evaluate any string as Rust, JavaScript, shell, template, or other programming code. Serde, quick-xml, and Rust are implementation choices, not language requirements.

2. Lexical Format

2.1. Encoding and Structural Grammar

Documents MUST be encoded in UTF-8 without a BOM. Permitted characters are U+0009, U+000A, U+000D, U+0020–U+D7FF, U+E000–U+FFFD, and U+10000–U+10FFFF, matching XML 1.0 Char. The language is a restricted XML subset and adopts no other general XML processor rules.

Element and attribute names are case-sensitive; opening/closing tags and attribute quotes MUST match. Duplicate attributes, non-whitespace text between elements, and trailing content after the root element MUST be rejected. Comments are permitted between elements, but -- MUST NOT appear inside a comment. XML declarations, DTDs, entity declarations, namespaces, processing instructions, CDATA sections, and mixed content MUST be rejected.

In the PEG below, ~ is sequence, | is ordered choice, */+ are repetition, ! is negative lookahead, and ANY is one permitted character. Tag matching, entity validity, and semantic constraints are checked separately:

Document  <- SOI ~ Gap* ~ Element ~ Gap* ~ EOI
Gap       <- Space | Comment
Space     <- " " | "\t" | "\r" | "\n"
Comment   <- "<!--" ~ (!"--" ~ ANY)* ~ "-->"
Element   <- Empty | Paired
Empty     <- "<" ~ XmlName ~ (Space+ ~ Attribute)* ~ Space* ~ "/>"
Paired    <- "<" ~ XmlName ~ (Space+ ~ Attribute)* ~ Space* ~ ">"
             ~ Gap* ~ (Element ~ Gap*)* ~ "</" ~ XmlName ~ Space* ~ ">"
XmlName   <- [A-Za-z_] ~ [A-Za-z0-9_-]*
Attribute <- XmlName ~ Space* ~ "=" ~ Space* ~ Quoted
Quoted    <- '"' ~ (!('"' | "<") ~ ANY)* ~ '"'
           | "'" ~ (!("'" | "<") ~ ANY)* ~ "'"

2.2. Attribute Decoding and Literal Syntax

Only the five named entities &amp;, &lt;, &gt;, &quot;, and &apos; are allowed. Decimal &#DIGITS; and hexadecimal &#xHEXDIGITS; character references MUST contain at least one digit and resolve to a permitted character. Bare &, unknown entities, missing semicolons, surrogates, and out-of-range code points MUST be rejected. Decoding runs exactly once: &amp;lt; decodes to &lt;, not <.

All decoded whitespace, including literal tabs and newlines, MUST be preserved verbatim. Consumers MUST NOT perform implicit XML attribute-value whitespace normalization, newline rewriting, Unicode normalization, or trimming; generic XML libraries may require adaptation.

Decoded token kind Grammar
Identifier [A-Za-z_][A-Za-z0-9_-]*
Boolean true or false only
Unsigned integer [0-9]+ (decimal)
Signed integer -?[0-9]+ (decimal)

Leading zeros are allowed; leading +, decimals, exponents, and surrounding whitespace are disallowed; -0 equals zero. Display labels, plain strings, and enum option values need not be identifiers.

3. Document Structure

The root element MUST be config-dsl with required attributes version="6" and target-version, plus optional locales and default-locale. target-version is opaque metadata, not a language version selector. locales is a whitespace-separated list of locale tags defaulting to zh-CN; default-locale MUST appear in locales and defaults to its first entry.

The root contains the top-level sections below. Unknown or duplicate sections MUST be rejected. Section order is insignificant; every section except inputs and outputs is optional and may appear at most once. Every top-level section other than ui MUST NOT carry attributes.

Section Required Purpose
ui No Branding, sections, and notices
strings No Locale-partitioned string pool
validators No Reusable field validators
inputs Yes Top-level input fields and collections
conditions No Named conditions
values No Named values
outputs Yes Output schema and export metadata
rules No Cross-field constraints
effects No Field reset triggers

3.1. String Pool strings

strings centralizes display text into locale-partitioned named entries:

<strings>
  <locale code="zh-CN"><entry name="ui.title" text="配置编辑器"/></locale>
  <locale code="en"><entry name="ui.title" text="Configuration editor"/></locale>
</strings>
  • locale MUST carry code belonging to root locales; at most one block per locale.
  • locale may contain only entry children; entry MUST carry non-empty name and text and have no children; name MUST be unique within each locale block.
  • entry name is a string-pool key: non-empty, not starting with an ASCII digit, and composed exclusively of [A-Za-z0-9._-] (permitting . for namespacing such as ui.title or builtin.add).
  • Every referenced name MUST exist in at least default-locale; missing translations fall back to default-locale. Unused entries are allowed.

Any display-text attribute may reference a pool entry via @string/<name> (e.g. label="@string/ui.title"). Values not starting with @string/ are treated as default-locale literals; referenced entries MUST exist. Behavioral values (default, enum value, filename, command, conditions, paths) are never localized.

The reference implementation reserves builtin. keys (such as builtin.add, builtin.generate, builtin.error.select) for framework chrome; descriptions may override them in the pool and fall back to built-in catalogs otherwise.

4. Interface ui

ui defines page branding, sections, and notices. Display attributes (title, brand, eyebrow, description, export-hint), section label/detail, and notice text all accept @string/<name> references. All attributes are syntactically optional; the reference implementation requires title and brand.

Attribute Meaning
title Page title
brand Brand name
mark Short brand monogram
eyebrow Auxiliary label above title
description Subtitle below title
export-hint Export region guidance
mode-field Top-level enum rendered as mode selector
format-field Top-level enum rendered as output format selector

mode-field and format-field MUST reference top-level enum fields. format-field options MUST be drawn from json, toml, and yaml (any non-empty subset is permitted); without format-field, JSON is used.

ui children are section and notice.

section:

Attribute Required Meaning
name Yes Section identifier referenced by inputs
label Yes Section heading
detail No Supplementary heading text
collapsed No Renders collapsed when true; defaults to false
when No Named condition controlling section visibility

notice:

Attribute Required Meaning
text Yes Plain-text notice (never parsed as HTML)
when No Named condition controlling visibility

A notice under ui appears in the export area; inside a section, it appears in that section. When no section is declared, consumers derive generic sections from input section attributes; once any section is declared, all regular fields and collections MUST reference a declared section.

5. Inputs inputs

inputs contains field and collection elements sharing one top-level namespace with unique names.

5.1. Field field

Attribute Required Meaning
name Yes Input identifier
type Yes string, boolean, integer, or enum
default Yes Initial value decoded according to type
label Yes Plain-text label
placeholder No Placeholder text
hint No Help text
section No Target UI section
widget No text, password, number, or email (string only)
when No Named condition governing visibility and validation
rule No Named validator reference
generator No uuid-v4 or hex (string only)
bytes No hex only; random byte count 1–1024, default 24
Type Default constraint Control
string Raw string Text input refined by widget
boolean true or false only Checkbox
integer Non-negative decimal integer Numeric input
enum Must match a child option Select dropdown

enum fields MUST contain one or more option children; non-enum fields MUST NOT have children.

option:

Attribute Required Meaning
value Yes Enum value, unique within the field
label Yes Option display text
description No Per-line preview explanation for this value (Section 11.4)

widget does not change data types: type="string" widget="number" remains a string. widget="password" does not imply output redaction; redaction is declared via secret="true" on output nodes.

generator produces random values on initial load, row addition, and generate actions: uuid-v4 uses 16 random bytes with RFC 4122 version/variant bits; hex encodes bytes random bytes in lowercase hex. XML defaults do not embed generated credentials.

A false when excludes a field from display and normal validation, but MUST NOT clear its stored value. Conditions are not access control and do not prevent outputs from reading a field.

5.2. Collection collection

collection declares a repeatable set of homogeneous rows whose child field elements follow Section 5.1 (without per-row section/hint layout rendering).

Attribute Required Meaning
name Yes Collection identifier
initial-items Yes Initial row count (0–1000)
label No Row label, defaulting to name
section No Target UI section
hint No Collection help text
add-label No Add button label; defaults to @string/builtin.add
generate-label No Generate button label; defaults to @string/builtin.generate
min-items No Minimum retained rows (0–1000), not exceeding initial-items
selected-by No Top-level integer field controlling active row selection
all-when No When true, edit and validate all rows; otherwise only the selected row
select-when No Enables selector UI and index validation; defaults to always enabled
when No Collection visibility and validation condition

selected-by MUST reference a top-level integer field used by at most one collection; all-when and select-when require selected-by. Collection when evaluates at Root; row field when evaluates per applicable row. Deleting the selected row resets the index to zero; deleting an earlier row decrements it. Stable UI row IDs, selection controls, credential generation, and deletion belong to the Host and are not exported automatically.

6. Conditions conditions

conditions contains condition name="ID" entries, each wrapping exactly one condition child with unique names. Condition elements cannot carry name, when, or transform:

Element Attributes Children and semantics
all / any None One or more conditions; logical AND / OR
not None Exactly one condition; logical negation
use Required ref None; references a named condition
eq Exactly one of from/ref, required value None; compares scalar textual form against literal
truthy Exactly one of from/ref None; requires and returns a boolean
ip Exactly one of from/ref None; checks valid IPv4/IPv6 literal
valid Exactly one of from/ref, required rule None; runs a declared validator
compare Required op="ne|gte" Exactly two value elements; inequality (ne) or non-negative integer >= (gte)

all/any MUST short-circuit left-to-right and propagate errors rather than treating errors as false. eq compares scalar textual representations: strings verbatim, booleans as true/false, integers as canonical decimal ("01" does not equal value="1", whereas integer 1 does). truthy never coerces numbers or strings. ip does not trim whitespace, strip brackets, or query DNS.

Every when attribute MUST reference a declared condition; undeclared references MUST be rejected.

7. Values values

values contains value name="ID" entries, each wrapping exactly one value child with unique names in a namespace separate from conditions. Every value element accepts optional when, evaluated before reading sources or children; when false it yields an absent value.

Element Attributes besides when Children
source Exactly one of from/ref, optional transform None
coalesce None One or more value elements
endpoint None Exactly two value elements (host and port)
select Required from, index Exactly one value element

coalesce returns the first candidate that is neither absent nor the empty string, preserving false, 0, empty lists, and empty objects; if none match, it returns "". endpoint requires a string host and integer port 1–65535, producing [host]:port for unbracketed IPv6 and host:port otherwise. select reads a list and zero-based non-negative index in the caller context, then evaluates its child on the selected row; missing data, type mismatches, or out-of-bounds indices MUST fail.

7.1. Fixed Transforms transform

transform and key-transform contain a whitespace-separated non-empty sequence of operations (default: identity). Each operation requires a string input:

Operation Result
trim Strip leading and trailing whitespace
lowercase Locale-independent lowercase
unbracket Strip matching leading [ and trailing ] if both present
integer Parse decimal non-negative integer
socket Canonicalize IP endpoint as a comparable key
port Extract integer port from an IP endpoint

No implicit coercions exist: applying a string operation after integer fails because the intermediate value is numeric. unit applies only to string output nodes and MUST be s or ms: it requires an integer after transforms and appends the suffix without scaling.

8. Validators validators

validators contains validator entries defining reusable field checks:

Attribute Required Meaning
name Yes Unique validator identifier
kind Yes Check kind (table below)
message Yes Error message on failure
min / max No Non-negative integer bounds
transform No Transform sequence applied before checking
nonblank No When true, requires non-empty trimmed string
kind Check
required Trimmed string is non-empty
length UTF-8 byte length or list item count within min/max
integer Non-negative decimal safely parsed as u64 within min/max
optional-integer Empty string passes; non-empty checked as integer
host Connectable domain or IP (rejects wildcard listen addresses)
socket IP:port
endpoint domain-or-IP:port
email Basic email syntax
uuid Non-zero hyphenated UUID
domain DNS name
public-domain Dotted DNS name
loopback-socket IP:port whose IP is loopback

Field rule attributes MUST reference declared validators; undeclared rules MUST be rejected. Validators perform purely local syntax checks with no DNS queries, reachability probes, mail delivery checks, or TLS trust verification.

9. Cross-Field Rules rules

rules contains assert and unique:

Attribute Required Meaning
key Yes Target field key for error attachment
message Yes Error message on failure
when No Named condition
collection No Collection to evaluate per row
  • assert holds exactly one condition child and reports an error when false.
  • unique holds one or more value children and checks key uniqueness across all visible, validated rows.

key attaches errors to top-level fields by name or to row fields as collection.index.field. Existing errors on a field are retained. Use valid guards before numeric or endpoint comparisons.

10. Effects effects

effects contains reset:

Attribute Required Meaning
on Yes Triggering top-level field
target Yes Top-level field reset to its XML default

When on's effective value changes, target is restored to its XML default. Scripts and recursive cascading resets are not supported. Both on and target MUST reference declared top-level fields.

11. Outputs outputs

<outputs> takes no attributes. Its children define top-level outputs, typically named <object> nodes corresponding to exported files.

Output element Purpose
object Object with uniquely named child nodes
list List with exactly one unnamed item template
record Dynamic-key map with exactly one unnamed value template
string / boolean / integer Strictly typed scalars
enum String constrained to a top-level enum

All output nodes beneath outputs accept common attributes:

Attribute Meaning
name Member key, unique among siblings
when Named condition; when false, omits the subtree without reading inputs
secret When true, redacts value in preview
description Per-line preview explanation (Section 11.4)

Top-level object nodes also accept export metadata:

Attribute Meaning
label Output display name
filename Safe base filename without extension (extension follows format)
command Display-only launch command ({filename} substitutes full filename)

11.1. Scalars

string, boolean, integer, and enum additionally accept:

Attribute Applies to Meaning
from / ref All Data source (mutually exclusive with value and child value element)
value All Literal constant decoded per element type
transform All Transform sequence before type check
unit string only s or ms, appended to integer value
options enum only Required; references a top-level enum input

Exactly one of from, ref, value, or a single child value element MUST be supplied. Evaluation runs strictly in order: source → transform → unit → type check. enum outputs MUST belong to the referenced top-level enum.

11.2. Objects and Collections

  • object holds zero or more named output children without changing input scope.
  • list accepts optional from, where-field, equals, equals-from, and omit-empty. With from, the source MUST be a list and items are projected in order; without from, the template evaluates once on the caller row producing zero or one item. where-field MUST appear together with exactly one of equals or equals-from and requires from, filtering with eq scalar text semantics; equals-from is a data path evaluated on the caller row, so one list can be split into per-row sublists grouped by a parent field.
  • record requires from and key, with optional key-transform and omit-empty. For each row, the child template is evaluated, then key is read, transformed, and required to be a non-empty string; duplicate transformed keys MUST fail projection and never overwrite. Dynamic keys need not be identifiers.
  • omit-empty applies only to list and record (default false), omitting empty collections when true. Objects and scalars reject omit-empty. false, 0, and "" MUST NOT be implicitly omitted; hidden outputs never read their sources.

11.3. Redaction

Preview redaction runs on a successful projection: consumers MUST validate the value against the declared output schema, reject unknown fields or wrong types, and replace each secret="true" node with eight U+2022 bullets (••••••••). Entire objects or collections may be marked secret; map keys remain visible, as version 6 has no secret-key marker. Redaction MUST NOT re-evaluate conditions, read inputs, or mutate the projection, and is never used for export or validation. Copy and download always export the unredacted projection.

11.4. Preview Descriptions

description is display-only metadata and MUST NOT affect projection, validation, redaction, or serialization, nor be interpreted as markup or code. Previews render line descriptions structurally:

  • object matches by member name;
  • list reuses its single item template;
  • record renders each dynamic entry with its single child template;
  • enum prefers the selected option's description, falling back to the output node's description.

12. Paths and Scope

Data paths are strictly single-segment: /name (Root) or name (current Row), using ASCII letters, digits, _, and -. Dotted paths, parent traversal, wildcards, and implicit array indexing are unsupported. Outside collection operations, Row equals Root; output object nodes do not alter input scope and output names are not interpreted as input paths.

when and use ref resolve in the condition namespace; other ref attributes resolve in the value namespace. Named conditions inherit the caller's Row; named values always evaluate at Root even when referenced inside a collection. Consumers MUST reject undeclared symbols and missing input paths, and MUST detect dependency cycles across definitions regardless of whether a definition is used.

13. Limits and Security

Descriptions MUST NOT exceed 1,048,576 UTF-8 bytes. With <config-dsl> at depth 0, element depth beyond 64 MUST be rejected. Each collection's initial-items is capped at 1000. Consumers MUST enforce limits before recursion or large allocations and fail cleanly without truncating or partially exporting data.

Descriptions MUST NOT trigger filesystem access, DNS, HTTP, subprocesses, environment variable expansion, or code execution. Diagnostics MUST NOT include submitted field values or sensitive source excerpts, SHOULD identify the failing stage (description, input, projection, serialization) and a safe logical path, and SHOULD report 1-based line and column numbers. Generated configurations do not verify target DNS, files, firewalls, TLS, or connectivity.

14. Complete Example

Sensitive fields default to empty strings; this example illustrates format only and is not ready for deployment.

<config-dsl version="6" target-version="example" locales="zh-CN en" default-locale="zh-CN">
  <ui title="@string/ui.title" brand="Example" mark="E" format-field="encoding">
    <section name="general" label="@string/section.general"/>
  </ui>
  <strings>
    <locale code="zh-CN">
      <entry name="ui.title" text="示例配置"/>
      <entry name="section.general" text="常规"/>
    </locale>
    <locale code="en">
      <entry name="ui.title" text="Example Configuration"/>
      <entry name="section.general" text="General"/>
    </locale>
  </strings>
  <inputs>
    <field name="encoding" type="enum" default="json" label="Output format">
      <option value="json" label="JSON"/>
      <option value="toml" label="TOML"/>
    </field>
    <field name="host" type="string" default=" [2001:db8::1] " label="Host" section="general"/>
    <field name="port" type="string" default="0443" label="Port" section="general" widget="number"/>
    <field name="auth" type="boolean" default="false" label="Auth" section="general"/>
    <field name="active" type="integer" default="0" label="Selected row" section="general"/>
    <collection name="users" initial-items="1" section="general">
      <field name="key" type="string" default="demo" label="Key"/>
      <field name="secret" type="string" default="" label="Secret" widget="password"/>
    </collection>
  </inputs>
  <conditions>
    <condition name="auth"><truthy from="/auth"/></condition>
  </conditions>
  <values>
    <value name="host"><source from="/host" transform="trim unbracket"/></value>
  </values>
  <outputs>
    <object name="example" label="Example" filename="example" command="example --config {filename}">
      <string name="server" description="Server endpoint.">
        <endpoint><source ref="host"/><source from="/port" transform="integer"/></endpoint>
      </string>
      <boolean name="enabled" from="/auth" description="Whether enabled."/>
      <list name="alpn" description="ALPN list."><string value="h3" description="HTTP/3 identifier."/></list>
      <string name="selected" description="Currently selected user key.">
        <select from="/users" index="/active"><source from="key"/></select>
      </string>
      <record name="users" from="/users" key="key" key-transform="trim lowercase" when="auth" description="User map.">
        <string from="secret" secret="true" description="User secret."/>
      </record>
    </object>
  </outputs>
</config-dsl>

Default projection (auth = false):

{"example":{"server":"[2001:db8::1]:443","enabled":false,"alpn":["h3"],"selected":"demo"}}

15. References

Normative references are RFC 2119 and RFC 8174 for requirement keywords, and XML 1.0 Characters for Section 2.1. All other lexical and evaluation rules are defined by this specification.

Appendix A. Element and Attribute Reference (Informative)

Top-level sections: ui, strings, validators, inputs, conditions, values, outputs, rules, effects (* required).

Element Key attributes Children
config-dsl version, target-version, locales, default-locale Top-level sections
ui title, brand, mark, eyebrow, description, export-hint, mode-field, format-field section, notice
section name, label, detail, collapsed, when notice
notice text, when —
strings — locale
locale code entry
entry name, text —
field name, type, default, label, placeholder, hint, section, widget, when, rule, generator, bytes option
option value, label, description —
collection name, initial-items, label, section, hint, add-label, generate-label, min-items, selected-by, all-when, select-when, when field
condition name Condition element
value name Value element
validator name, kind, message, min, max, transform, nonblank —
assert / unique key, message, when, collection Condition / value element
reset on, target —
outputs — Output elements
object name, when, secret, label, filename, command, description Output elements
list name, when, secret, from, where-field, equals, equals-from, omit-empty, description 1 unnamed output element
record name, when, secret, from, key, key-transform, omit-empty, description 1 unnamed output element
string / boolean / integer / enum name, when, secret, from/ref/value, transform, unit, options, description At most 1 value element