/yon-write
YON Writing & Compilation Mode — create, generate, or convert content into YON (YounndAI Object Notation), a line-oriented, stream-first Cognitive Architecture for AI systems.
The Encoding Principle
Foundational contract: YON preserves what the emitter wants to send. An encoder preserves what was said. A translator decides what was meant. YON is an encoder.
"probably purple" stays "probably purple" — do not resolve to confidence: 0.6
"like everyone else does" stays verbatim — do not interpret vague social references
- Hedging, uncertainty, and conversational nuance are preserved exactly
- Links, paths, URLs are preserved byte-for-byte. Never alias, shorten, or rewrite.
- The human's intent is sovereign. The encoding layer is faithful to the source. Interpretation is downstream.
When NOT to Generate YON
YON is a Cognitive Architecture for AI pipelines, not a universal data format. Do not use it for:
- API responses — YON adds +54–185% size vs JSON minified for pure data payloads
- Config files — TOML or YAML are better for human-edited configuration
- Short messages under ~340 tokens — plain text is cheaper at small context sizes
- Database records — use JSON, Protobuf, or native formats
- Simple key-value data — YON's structural baseline adds no benefit for flat data
YON belongs in: system prompts, agent instructions, multi-hop pipelines, rules/policies, workflows, cognitive traces, provenance tracking, and anywhere intent + data + audit travel together.
Decision Gate — Before You Write
1. Choose Profile
| Profile |
Use When |
core |
Basic structure (docs, notes) |
decl |
Rules and schemas (policies, configs) |
exec |
Workflows (steps, checks, error handling) |
audit |
Provenance tracking |
cognitive |
AI thought chains |
agent |
Multi-agent systems |
2. Choose Format
| Format |
Use Case |
canon |
Human docs, reference material |
min |
LLM pipelines, agents (recommended default) |
ultra |
Cost-critical transport |
3. Choose Kind
doc, rule, workflow, skill, sidecar, spec, context, memory, note, prompt
Output Rules
When writing to a .yon file: Output YON records ONLY. No markdown, no fenced blocks, no commentary. Pure YON.
When showing YON in conversation: Use a fenced code block and briefly explain your choices (profile, kind, key decisions made during encoding).
Always:
- First non-comment line MUST be
@DOC
- Separator: ALWAYS
| (space, pipe, space)
- Bare values when matching
[A-Za-z0-9_./:@+#-]+, otherwise double-quote
- Values containing
| MUST be quoted: regex="a|b|c"
- Typed keys for non-strings:
n:int=3, active:bool=true, ts:ts=2026-01-01T00:00:00Z
@MAP pairs: BOTH sides quoted: pairs=["key"->"value"]
@BEGIN/@END blocks: mime= required, boundary= 8+ chars, id= required when multiple blocks or referenced
- Self-describing docs: add
guide="https://yon.younndai.com/yon-guide.txt" when the document targets LLMs without YON knowledge
Required Fields Per Tag
| Tag |
Required Fields |
@DOC |
ver, id, title |
@SEC |
name |
@NOTE |
text |
@STAMP |
ts, src |
@RULE |
lvl (MUST/MUST_NOT/SHOULD/SHOULD_NOT/MAY), when, then |
@MAP |
name, pairs |
@CFG |
id, set |
@INTENT |
goal |
@CHECK |
rid, assert, fail (ABORT/WARN/SKIP), msg |
@STEP |
rid, n:int, op |
@CATCH |
target, on, do |
@RETRY |
target, max |
@PATCH |
ts, target, set |
@VOID |
ts, target |
@REDACTION |
target, reason |
@CONSENT |
party, scope |
Conversion Patterns
Prose → Rules
"Always" / "Must" → lvl=MUST
"Never" / "Must not" → lvl=MUST_NOT
"Prefer" / "Should" → lvl=SHOULD
"Optional" / "May" → lvl=MAY
Tables → Schema / Map / Cfg
- Enum/Choices →
@SCHEMA key=severity | opts=[low,med,high] | default=med
- Condition→Outcome →
@MAP pairs=["input"->"output"]
- Multi-setting →
@CFG id=X | set=[k=v] then @MAP pairs=["ctx"->"cfg:X"]
Code/JSON/Logs → Blocks
@BEGIN CODE | id=handler | mime="text/x-python" | boundary="bnd_py_001"
def hello():
return "world"
@END CODE | boundary="bnd_py_001"
List Constraints
in/out: reference tokens ONLY (block:, rid:, cfg:, ref:, file:, url:, agent:, etc.)
args/set: field items ONLY (key=value, key:type=value)
pairs: map pairs ONLY ("k"->"v")
- Depth limit = 1. No nested lists.
Worked Example: Prose → YON
Input (user's messy prose):
"ok so we need an api rate limiting thing. all calls must have auth tokens. standard users get 100/min, premium 500. if they hit the limit they should probably back off exponentially. never expose internal errors in responses."
Output:
@DOC ver=2.0 | id=api-rate-policy | title="API Rate Limiting Policy" | kind=rule | profile=decl | fmt=min
@INTENT goal="Define authentication and rate limiting standards for public API"
@SEC name="Authentication"
@RULE rid=rule:auth | lvl=MUST | when="calling any API endpoint" | then="include valid auth token"
@SEC name="Rate Limits"
@MAP name=TierLimits | pairs=["standard"->"100/min","premium"->"500/min"]
@RULE rid=rule:backoff | lvl=SHOULD | when="rate limit exceeded" | then="probably back off exponentially"
@SEC name="Error Handling"
@RULE rid=rule:errors | lvl=MUST_NOT | when="returning API response" | then="expose internal error details"
@STAMP ts:ts=2026-03-30T12:00:00Z | src=human
What the encoding did: Detected section boundaries from topic shifts. "must" → MUST, "never" → MUST_NOT, "should probably" → SHOULD. Preserved "probably back off exponentially" verbatim (hedging preserved). Dropped "ok so" and "thing" (zero semantic content).
What the encoding did NOT do: Did not resolve "probably" into a confidence level. Did not reorder the user's sequence. Did not add fields the user didn't mention.
Handling Ambiguous Input
When the input doesn't map cleanly to YON:
- Unclear when/then split: Use a broad
when (e.g., when="in all contexts") and put the action in then. Don't fabricate conditions.
- Mixed intent and data: Put purpose in
@INTENT, constraints in @RULE, factual descriptions in @NOTE. When unsure, @NOTE is the safe default.
- Vague severity: Default to
SHOULD and flag with note="severity inferred — confirm with author"
- Nested/complex structures: Flatten. Use
@CFG for grouped settings, @BEGIN/@END blocks for verbatim payloads. Depth limit is 1.
Validation Checklist
After writing, verify:
Record Order (Recommended)
@DOC → @STAMP → @META → @DEF → @REF → @INTENT → @SCOPE → @SEC sections → @BEGIN/@END blocks
Detailed References
For edge cases, extended syntax, and complete examples:
- references/write-card.txt — Complete compilation reference card with one-shot examples
- references/domains-card.txt — All profiles, formats, kinds, and official domain list
- references/generation-guide.md — Comprehensive examples: rules, workflows, cognitive traces, multi-agent, prose encoding
Full spec: https://yon.younndai.com
1---2name: yon-write3description: YON Writing & Compilation Mode. Use when creating, generating, converting, or writing YON content. Triggers on: "write YON", "convert to YON", "create a .yon file", "encode this as YON", "YON format", or any request where the expected output is YON records. Also triggers when unstructured content should be structured into YON even without explicit keyword — e.g., working in a YON project. Use yon-read instead when reading, interpreting, explaining, or summarizing existing YON.4---56# /yon-write78YON Writing & Compilation Mode — create, generate, or convert content into YON (YounndAI Object Notation), a line-oriented, stream-first Cognitive Architecture for AI systems.910## The Encoding Principle1112**Foundational contract: YON preserves what the emitter wants to send. An encoder preserves what was said. A translator decides what was meant. YON is an encoder.**1314- `"probably purple"` stays `"probably purple"` — do not resolve to `confidence: 0.6`15- `"like everyone else does"` stays verbatim — do not interpret vague social references16- Hedging, uncertainty, and conversational nuance are preserved exactly17- Links, paths, URLs are preserved byte-for-byte. Never alias, shorten, or rewrite.18- The human's intent is sovereign. The encoding layer is faithful to the source. Interpretation is downstream.1920## When NOT to Generate YON2122YON is a Cognitive Architecture for AI pipelines, not a universal data format. Do not use it for:2324- **API responses** — YON adds +54–185% size vs JSON minified for pure data payloads25- **Config files** — TOML or YAML are better for human-edited configuration26- **Short messages under ~340 tokens** — plain text is cheaper at small context sizes27- **Database records** — use JSON, Protobuf, or native formats28- **Simple key-value data** — YON's structural baseline adds no benefit for flat data2930YON belongs in: system prompts, agent instructions, multi-hop pipelines, rules/policies, workflows, cognitive traces, provenance tracking, and anywhere intent + data + audit travel together.3132## Decision Gate — Before You Write3334### 1. Choose Profile3536| Profile | Use When |37|-----------|------------------------------------------------------|38| `core` | Basic structure (docs, notes) |39| `decl` | Rules and schemas (policies, configs) |40| `exec` | Workflows (steps, checks, error handling) |41| `audit` | Provenance tracking |42| `cognitive` | AI thought chains |43| `agent` | Multi-agent systems |4445### 2. Choose Format4647| Format | Use Case |48|---------|-------------------------------------------|49| `canon` | Human docs, reference material |50| `min` | LLM pipelines, agents (recommended default) |51| `ultra` | Cost-critical transport |5253### 3. Choose Kind5455`doc`, `rule`, `workflow`, `skill`, `sidecar`, `spec`, `context`, `memory`, `note`, `prompt`5657## Output Rules5859**When writing to a `.yon` file:** Output YON records ONLY. No markdown, no fenced blocks, no commentary. Pure YON.6061**When showing YON in conversation:** Use a fenced code block and briefly explain your choices (profile, kind, key decisions made during encoding).6263**Always:**64- First non-comment line MUST be `@DOC`65- Separator: ALWAYS ` | ` (space, pipe, space)66- Bare values when matching `[A-Za-z0-9_./:@+#-]+`, otherwise double-quote67- Values containing `|` MUST be quoted: `regex="a|b|c"`68- Typed keys for non-strings: `n:int=3`, `active:bool=true`, `ts:ts=2026-01-01T00:00:00Z`69- `@MAP` pairs: BOTH sides quoted: `pairs=["key"->"value"]`70- `@BEGIN`/`@END` blocks: `mime=` required, `boundary=` 8+ chars, `id=` required when multiple blocks or referenced71- Self-describing docs: add `guide="https://yon.younndai.com/yon-guide.txt"` when the document targets LLMs without YON knowledge7273## Required Fields Per Tag7475| Tag | Required Fields |76|--------------|-------------------------------------------------------------------------------|77| `@DOC` | `ver`, `id`, `title` |78| `@SEC` | `name` |79| `@NOTE` | `text` |80| `@STAMP` | `ts`, `src` |81| `@RULE` | `lvl` (MUST/MUST_NOT/SHOULD/SHOULD_NOT/MAY), `when`, `then` |82| `@MAP` | `name`, `pairs` |83| `@CFG` | `id`, `set` |84| `@INTENT` | `goal` |85| `@CHECK` | `rid`, `assert`, `fail` (ABORT/WARN/SKIP), `msg` |86| `@STEP` | `rid`, `n:int`, `op` |87| `@CATCH` | `target`, `on`, `do` |88| `@RETRY` | `target`, `max` |89| `@PATCH` | `ts`, `target`, `set` |90| `@VOID` | `ts`, `target` |91| `@REDACTION` | `target`, `reason` |92| `@CONSENT` | `party`, `scope` |9394## Conversion Patterns9596### Prose → Rules97- `"Always"` / `"Must"` → `lvl=MUST`98- `"Never"` / `"Must not"` → `lvl=MUST_NOT`99- `"Prefer"` / `"Should"` → `lvl=SHOULD`100- `"Optional"` / `"May"` → `lvl=MAY`101102### Tables → Schema / Map / Cfg103- Enum/Choices → `@SCHEMA key=severity | opts=[low,med,high] | default=med`104- Condition→Outcome → `@MAP pairs=["input"->"output"]`105- Multi-setting → `@CFG id=X | set=[k=v]` then `@MAP pairs=["ctx"->"cfg:X"]`106107### Code/JSON/Logs → Blocks108```109@BEGIN CODE | id=handler | mime="text/x-python" | boundary="bnd_py_001"110def hello():111 return "world"112@END CODE | boundary="bnd_py_001"113```114115### List Constraints116- `in`/`out`: reference tokens ONLY (`block:`, `rid:`, `cfg:`, `ref:`, `file:`, `url:`, `agent:`, etc.)117- `args`/`set`: field items ONLY (`key=value`, `key:type=value`)118- `pairs`: map pairs ONLY (`"k"->"v"`)119- Depth limit = 1. No nested lists.120121## Worked Example: Prose → YON122123**Input (user's messy prose):**124> "ok so we need an api rate limiting thing. all calls must have auth tokens. standard users get 100/min, premium 500. if they hit the limit they should probably back off exponentially. never expose internal errors in responses."125126**Output:**127```128@DOC ver=2.0 | id=api-rate-policy | title="API Rate Limiting Policy" | kind=rule | profile=decl | fmt=min129@INTENT goal="Define authentication and rate limiting standards for public API"130131@SEC name="Authentication"132@RULE rid=rule:auth | lvl=MUST | when="calling any API endpoint" | then="include valid auth token"133134@SEC name="Rate Limits"135@MAP name=TierLimits | pairs=["standard"->"100/min","premium"->"500/min"]136@RULE rid=rule:backoff | lvl=SHOULD | when="rate limit exceeded" | then="probably back off exponentially"137138@SEC name="Error Handling"139@RULE rid=rule:errors | lvl=MUST_NOT | when="returning API response" | then="expose internal error details"140141@STAMP ts:ts=2026-03-30T12:00:00Z | src=human142```143144**What the encoding did:** Detected section boundaries from topic shifts. `"must"` → MUST, `"never"` → MUST_NOT, `"should probably"` → SHOULD. Preserved `"probably back off exponentially"` verbatim (hedging preserved). Dropped `"ok so"` and `"thing"` (zero semantic content).145146**What the encoding did NOT do:** Did not resolve `"probably"` into a confidence level. Did not reorder the user's sequence. Did not add fields the user didn't mention.147148## Handling Ambiguous Input149150When the input doesn't map cleanly to YON:151152- **Unclear when/then split:** Use a broad `when` (e.g., `when="in all contexts"`) and put the action in `then`. Don't fabricate conditions.153- **Mixed intent and data:** Put purpose in `@INTENT`, constraints in `@RULE`, factual descriptions in `@NOTE`. When unsure, `@NOTE` is the safe default.154- **Vague severity:** Default to `SHOULD` and flag with `note="severity inferred — confirm with author"`155- **Nested/complex structures:** Flatten. Use `@CFG` for grouped settings, `@BEGIN`/`@END` blocks for verbatim payloads. Depth limit is 1.156157## Validation Checklist158159After writing, verify:160161- [ ] Exactly one `@DOC`, first non-comment record162- [ ] All `@BEGIN` have matching `@END` with same TAG and boundary163- [ ] All `@BEGIN` include `mime=`164- [ ] No duplicate keys within a single record165- [ ] `@MAP` uses `pairs=[...]` with both sides quoted166- [ ] Canonical separator ` | ` used consistently167- [ ] All required fields present for each tag168- [ ] `@RULE` with `lvl=MUST` or `MUST_NOT` are individual records (never merged/summarized)169170## Record Order (Recommended)171172`@DOC` → `@STAMP` → `@META` → `@DEF` → `@REF` → `@INTENT` → `@SCOPE` → `@SEC` sections → `@BEGIN`/`@END` blocks173174## Detailed References175176For edge cases, extended syntax, and complete examples:177178- [references/write-card.txt](references/write-card.txt) — Complete compilation reference card with one-shot examples179- [references/domains-card.txt](references/domains-card.txt) — All profiles, formats, kinds, and official domain list180- [references/generation-guide.md](references/generation-guide.md) — Comprehensive examples: rules, workflows, cognitive traces, multi-agent, prose encoding181182Full spec: https://yon.younndai.com