$ fssg build --deterministic --validate |

FACET vs YAML vs JSON: Why AI Needs Its Own Language

FACET

For 15 years, I've been building systems with JSON and YAML. Configuration files, API specs, CI/CD pipelines—the works. These formats served me well.

Then I started building AI systems.

Suddenly, everything broke down. Same prompt, different outputs. No way to enforce contracts. Copy-paste hell across environments. Even temperature=0 didn't solve the fundamental chaos.

The frustrating truth: JSON and YAML were designed for configuration, not for AI orchestration.

So I built FACET—a language purpose-built for deterministic AI systems.

This isn't about replacing JSON or YAML everywhere. It's about having the right tool for AI engineering.


The Wake-Up Call

I was working on AstroVisor.io—an AI astrology platform with 95+ endpoints. The prompt configurations were YAML files. Standard practice, right?

Here's what actually happened:

Every module (natal charts, transits, progressions) needed similar constraints: "Use Swiss Ephemeris", "Precision to 0.001 arcsec", "Traditional interpretations only."

In YAML, I copy-pasted these constraints 43 times across different modules. When a compliance requirement changed, I had to update 43 files. Miss one? Production incident.

The real killer: No type safety. A typo like precission instead of precision? Silent failure. Discovered only when a user complained about wrong calculations.

I thought: "There has to be a better way."


What Makes AI Specifications Different

Traditional config files handle static data: database URLs, feature flags, timeout values. You set them once, they don't change.

AI systems need dynamic specifications:

  • Prompts that transform based on environment
  • Output contracts that validate LLM responses
  • Deterministic randomness for A/B testing
  • Modular reuse across agents
  • Type safety to catch errors before LLM invocation

JSON and YAML weren't designed for any of this.


Problem 1: The Multiline String Hell

Let me show you a real prompt from production:

{
  "system": {
    "prompt": "You are a professional astrologer.\n\nUse Swiss Ephemeris for all calculations.\n\nProvide interpretations in a warm, professional tone.\n\nAlways cite your sources."
  }
}

What's wrong here?

First, it's unreadable. Those \n escape sequences make editing painful. Second, try adding a paragraph. You'll spend more time managing escape sequences than actual content.

In YAML, it's better but not great:

system:
  prompt: |
    You are a professional astrologer.
    
    Use Swiss Ephemeris for all calculations.
    
    Provide interpretations in a warm, professional tone.
    
    Always cite your sources.

The | syntax works, but there's no way to clean up indentation or normalize whitespace programmatically.

In FACET, it's natural:

@system
  prompt: """
    You are a professional astrologer.
    
    Use Swiss Ephemeris for all calculations.
    
    Provide interpretations in a warm, professional tone.
    
    Always cite your sources.
  """ |> dedent |> trim

The |> dedent |> trim pipeline removes common indentation and trailing whitespace. What you see is what you get, plus deterministic cleanup.

Why this matters: When you're managing 50+ prompts, readability compounds. Small friction adds up to massive productivity loss.


Problem 2: The Norway Problem (YAML's Fatal Flaw)

Here's a YAML file that looks innocent:

countries:
  norway: NO
  sweden: SE
  denmark: DK

Pop quiz: What type is NO?

If you said "string", you're wrong. YAML interprets NO as boolean false.

This isn't theoretical. I've seen production bugs where country codes broke entire systems because YAML silently converted NO, YES, ON, OFF to booleans.

Other YAML surprises:

  • 1234 → number
  • 01234 → octal number (666 in decimal!)
  • 0xFF → 255 in decimal
  • 12:30 → 750 (12*60 + 30)

YAML tries to be "smart" about types. In practice, it's a minefield.

FACET approach: Explicit is better than implicit.

@countries
  norway: "NO"  # Always a string
  sweden: "SE"
  denmark: "DK"

No magic. No surprises. No silent conversions.


Problem 3: The DRY Principle Killer

Let's say you have three environments: dev, staging, production. Each needs the same timeout and retry settings but different API URLs.

In JSON:

{
  "dev": {
    "api_url": "http://localhost:8000",
    "timeout": 30,
    "retry": 3,
    "rate_limit": 100
  },
  "staging": {
    "api_url": "https://staging.example.com",
    "timeout": 30,
    "retry": 3,
    "rate_limit": 100
  },
  "prod": {
    "api_url": "https://api.example.com",
    "timeout": 30,
    "retry": 3,
    "rate_limit": 100
  }
}

Change timeout from 30 to 60? Update three places. Forget one? Inconsistent behavior across environments.

YAML has anchors, but they're limited:

defaults: &defaults
  timeout: 30
  retry: 3

dev:
  <<: *defaults
  api_url: http://localhost

The <<: syntax is obscure, and anchors can't handle conditionals or cross-file references cleanly.

FACET solves this with variables and conditionals:

@vars
  env: "prod"  # Change once, affects everything
  timeout: 30
  retry: 3

@config(if="env=='dev'")
  api_url: "http://localhost:8000"

@config(if="env=='staging'")
  api_url: "https://staging.example.com"

@config(if="env=='prod'")
  api_url: "https://api.example.com"

@config
  timeout: $timeout
  retry: $retry

Change timeout once in @vars, it propagates everywhere. Change env variable, different config activates. Zero duplication.


Problem 4: No Contract Enforcement

Here's the scariest part of working with LLMs: they hallucinate freely.

You ask for structured output. You get markdown. You ask for JSON. You get JSON with missing required fields. You ask for numbers. You get strings.

Traditional configs offer zero help here.

What I needed: A way to specify output contracts and validate them before the response reaches users.

FACET contracts:

@output
  schema:
    type: "object"
    required: ["planet_positions", "house_cusps", "aspects"]
    properties:
      planet_positions: 
        type: "array"
        minItems: 10
      house_cusps:
        type: "array"
        minItems: 12
      aspects:
        type: "array"
        items:
          type: "object"
          required: ["planet1", "planet2", "angle", "type"]
  require:
    - "All calculations use Swiss Ephemeris"
    - "Precision to 0.001 arcseconds"
    - "Cite traditional sources for interpretations"

The schema section uses JSON Schema for structural validation. The require section adds semantic requirements that get injected into the system prompt.

Result: Contract violations caught early, before they become customer-facing incidents.


Problem 5: The Type Safety Gap

I once spent three hours debugging why an AI agent wasn't working. The problem? A typo:

temperature: 0.7
max_tokns: 1000  # Typo: "tokns" instead of "tokens"

YAML happily accepted it. The LLM API ignored the unknown field. The agent used default token limits, giving incomplete responses.

JSON and YAML have no built-in type system. You can add JSON Schema validation externally, but it's runtime-only and disconnected from your config format.

FACET has compile-time types:

@vars
  temperature: 0.7
  max_tokens: 1000
  model: "gpt-typo"

@var_types
  temperature: { type: "float", min: 0.0, max: 1.0 }
  max_tokens: { type: "int", min: 1, max: 4096 }
  model: { type: "string", enum: ["gpt-5-mini", "claude-4-opus"] }

Try to use temperature: 1.5? Error F451 at parse time. Try model: "gpt-typo"? Error F452 before you even call the API.

The difference: Shifting error detection from production back to development.


A Counterintuitive Truth: Structure Drives Creativity

When I tell people about FACET's strict syntax (exactly 2 spaces, no tabs, explicit types), they worry about creativity constraints.

But here's what I learned building AstroVisor:

Structure doesn't limit AI—it makes it more reliable and more creative.

The proof point: In testing, a meta-agent without its runtime read the FACET spec of a tool, synthesized its own interpreter, and completed the task. The deterministic structure gave it enough context to reason about the system.

Chaos isn't creativity. It's just noise. Real creativity comes from reliable foundations.


Real Numbers from Production

After migrating AstroVisor from YAML to FACET:

Code metrics:

  • 450 lines of YAML → 120 lines of FACET (73% reduction)
  • 43 duplicated constraint blocks → 0 duplications
  • Parse time: 45ms → 3.7ms (12× faster)

Developer Velocity:

  • Config change to production: 1 day → 1 hour
  • Type errors caught at compile time: 0% → 100%
  • A/B test variant creation: 30 minutes → 30 seconds

Reliability:

  • Production incidents from config errors: 3/month → 0/month
  • Time to debug type mismatches: 2 hours → 0 (caught at compile time)

These aren't projections. These are real numbers from 6 months of production use.


When to Use Each Format

I'm not saying "burn all your JSON and YAML files." Different tools for different jobs.

Use JSON for:

  • API payloads and responses
  • Database records
  • Simple data exchange
  • When you need universal tooling support

Use YAML for:

  • Application configs (Docker, Kubernetes)
  • CI/CD pipelines (GitHub Actions, GitLab CI)
  • Human-readable configs that don't require strict validation

Use FACET for:

  • AI prompt specifications
  • Multi-agent orchestration
  • Systems requiring determinism
  • Enterprise AI with compliance needs
  • A/B testing AI behaviors
  • Production AI systems at scale

The Determinism Guarantee

Here's the core principle that drove FACET's design:

One .facet file = One canonical JSON = One deterministic result

No matter who parses it, when they parse it, or where they parse it, the result is byte-for-byte identical.

Why this matters:

When you're running A/B tests on AI prompts, you need perfect reproducibility. When you're debugging agent behavior, you need to replay exact scenarios. When you're under audit, you need to prove what prompt was used.

YAML can't guarantee this (ambiguous types, parser differences). JSON can, but lacks the features for AI specs.

FACET gives you both: deterministic output and AI-native features.


What About Existing Tooling?

The biggest objection I hear: "But JSON and YAML have mature ecosystems!"

Fair point. Here's my counter:

The FACET ecosystem today:

  • Python parser: pip install facet-lang
  • MCP server for Claude integration
  • 15+ production agent specifications
  • RMCP protocol for agent orchestration
  • Growing community in GitHub Issues

Coming soon:

  • LSP (Language Server Protocol) for IDE support
  • VS Code extension with syntax highlighting
  • Web playground for experimentation
  • TypeScript and Rust SDKs

Yes, it's a younger ecosystem. But it's solving problems the incumbents were never designed to handle.


The Migration Is Simpler Than You Think

I didn't rewrite everything overnight. Here's how I migrated AstroVisor:

Week 1: Converted one critical module (natal charts) Week 2-3: Added @var_types to catch historical bugs Week 4: Extracted common patterns into @import files Month 2: Migrated remaining modules incrementally Month 3: Full production, 100% FACET

The mechanical part is easy: JSON/YAML maps cleanly to FACET. Automated conversion tools exist.

The valuable part takes time: Adding types, contracts, and proper modularity. But you get immediate value from day one.


What I Learned Building This

Lesson 1: Syntax matters less than semantics

FACET's syntax isn't revolutionary. It's the semantic features—types, contracts, lenses, conditionals—that solve real problems.

Lesson 2: Explicit beats implicit

YAML's "smart" type inference caused more bugs than it prevented. Explicit quoting and typing eliminates entire classes of errors.

Lesson 3: AI needs contracts

LLMs are powerful but unreliable. Without output schemas, you're debugging hallucinations in production. With schemas, you catch them at validation time.

Lesson 4: Determinism is achievable

Everyone said "AI is inherently non-deterministic." But with explicit seeds, pipeline transforms, and canonical representations, you can build reproducible AI systems.


The Bigger Picture

FACET is one piece of a larger vision: transforming AI development from ad-hoc prompt hacking into an engineering discipline.

The stack:

  • FACET Language — Deterministic specs with contracts
  • FACET MCP Server — High-performance execution engine
  • RMCP Protocol — Multi-agent orchestration
  • FACET Agents — 15+ specialized agents that self-improve

Each layer builds on determinism and contracts. FACET is the foundation.


Try It Today

If you're managing 5+ AI prompts, dealing with environment variants, or need audit trails for compliance, FACET might help.

Quick start:

pip install facet-lang
echo '@system
  role: "Expert"
@user  
  request: "Test"' | facet canon

Resources:

Next article: "FACET Language: Contracts and Determinism"—Deep dive into lenses, type systems, and production deployment patterns.


Final Thoughts

I built FACET because I was frustrated. Frustrated by YAML's quirks. Frustrated by JSON's limitations. Frustrated by the gap between "prompt engineering" and actual engineering.

FACET won't replace JSON and YAML everywhere. That's not the goal.

The goal: Give AI engineers the same discipline and guarantees that software engineers have taken for granted for decades. Types. Contracts. Determinism. Modularity.

If you're building AI systems that matter—systems where reliability isn't optional, where reproducibility is required, where compliance is critical—FACET might be the tool you didn't know you needed.

Because AI development shouldn't be a dark art. It should be engineering.


By Emil Rokossovskiy — Principal Engineer, AI Platforms & Creator of the FACET ecosystem. Thoughts? Join the discussion.

FACET AI CLI Terminal
facet@ai:~$