Skip to content

VIP-82: Machine representation mode and lossless human ↔ machine conversion

Status: accepted by Will, 2026-11-28.

Motivation

Empirical benchmarks across 30 verified Effect 4 programs and 342 live cached-skill agent trials (docs/user/benchmarks/agent-syntax/results.json) established two facts:

  1. Alien expression syntaxes hurt coding agents. Indentation-delimited (vibe-toon) and Lisp/S-expression (vibe-sexpr) formats shrank static code tokens, but inflicted up to +412.5% more hidden thinking tokens (2.6× cost, 2.5× slower) and collapsed small-model (claude-haiku-5-5) pass@1 from 90.9% to 40.9%.
  2. TypeScript-shaped compaction beats Effect 4 TypeScript on every metric. Keeping TypeScript's expression syntax, braces, and familiar Vibe keywords intact while compacting multi-token keyword heads and token-expensive whitespace cuts static tokens across the 30-task benchmark-30 corpus from 4,688 (human .vibe) to 3,960 (-15.5% vs human .vibe, -36.0% vs Effect 4 TS's 6,183 o200k_base tokens) at 1-space indentation — and 3,822 (-18.5% vs human .vibe, -38.2% vs Effect 4 TS) at 0-space indentation — verified 30/30 with the native VIP-82 compiler (30/30 byte-identical machine → human → machine round trip, 30/30 byte-identical .d.ts declarations, 30/30 byte-identical JavaScript, 30/30 expected runtime output). node docs/user/benchmarks/agent-syntax/verify-machine-mode.mjs --write regenerates these numbers (vip82MachineMode30Tasks).

Measuring candidate substitutions against o200k_base and cl100k_base shows why most Vibe keywords stay unchanged:

Candidate substitutionIncluded?
effect function / effect function* → ef / ef*Yes (multi-token head → 1 token)
uninterruptible / interruptible → unint / intrYes (multi-token word → compact head)
1-space indentation (from 2-space)Yes (default machine layout)
0-space flat indentation (optional --indent=0)Opt-in (--indent=0; -138 tokens against 1-space over the 30 tasks)
BPE-tight punctuation (:, ,, ;, =, =>, {, })Yes (whitespace/layout only, ASI-safe)
error → err, service → svc, schema → sch, provide → prov, effect { → ef {No (already 1 token; no saving)

VibeLang therefore defines one language and one AST with two lossless, 2-way convertible surface representations: human and machine.

Decision

1. Minor syntactic differences between human and machine forms

Human form and machine form share the entire VibeLang grammar, type system, lowering, emitted JavaScript, .d.vibe.ts declarations, and source-map contract. They differ in only two strictly contextual keyword pairs plus whitespace layout:

ConstructHuman formMachine formSpec chapter
Effect function declarationeffect function f(...) { ... }ef f(...) { ... }Functions
Exported effect functionexport effect function f(...)export ef f(...)Functions
Effect producer declarationeffect function* f(...) { ... }ef* f(...) { ... }Functions
Exported effect producerexport effect function* f(...)export ef* f(...)Functions
Effect method / producer methodeffect m(...) { ... } / effect* m(...) { ... }ef m(...) { ... } / ef* m(...) { ... }Functions
Interruption mask blocksuninterruptible { ... } / interruptible { ... }unint { ... } / intr { ... }Running Effects
Layout & spacingStandard repository formatter style (dprint / Prettier)1-space indent (or --indent=0) and BPE-tight punctuation spacing, on the same lines as the human formTooling

All other VibeLang constructs (error, service, schema, data, provide, try, catch, match, when, fork, join, for concurrent, for try, restore, effect { ... }, effect (...) => ..., A!E!R) are identical in both forms.

2. Contextual keyword safety rules

ef, unint, and intr are contextual keywords, never reserved words:

  • ef starts an effect function or producer declaration only when followed on the same line by an identifier (ef name(), * (ef* name(), or a class/object member name (ef name( / ef* name(), matching TypeScript's two-adjacent-identifiers rule. ef * fn(x) is a producer declaration only when a return type or, on the same line, the { of its body follows; with the brace on a later line it is the multiplication and the separate block it was before ef had a meaning. Ordinary identifiers and calls (const ef = 1, ef(x), obj.ef, class C { ef() {} }) keep their exact TypeScript meaning.
  • unint and intr start an interruption mask block only when followed by { on the same line (unint { ... }, intr { ... }), following VIP-22's isVibeLangMaskWord rule. Ordinary identifiers (const unint = true, intr(x)) keep their exact TypeScript meaning.
  • Both ef and effect function parse into the exact same FunctionDeclaration (with effect modifier flag), and unint/intr parse into the exact same interruption block AST nodes as uninterruptible/interruptible.
  • Inside module Name { ... } TypeScript bodies (VIP-40), ef, unint, and intr have no special meaning and are never rewritten.
  • Where ef does not start a declaration, the long form is the only spelling in both forms: an effect function expression (const f = effect function g() {}), a default export (export default effect function f() {}), an effect function named as, satisfies or is (after ef these continue an expression), an effect producer with no return type whose body is absent or starts on a later line (ef* f(x) multiplies), a head with a comment between effect and function (ef has no place to keep it), and a head with a line break between effect and the name. vibe convert --to=machine leaves these unchanged, and vibe.syntax: "machine" does not report them.

3. Configuration and CLI switches (vibe.syntax and --syntax)

Projects configure which spellings the compiler accepts via vibe.syntax in vibe.config.json, tsconfig.json, or jsconfig.json (extending VIP-30):

ValueBehavior
"both" (default)Accepts both human and machine spellings in the same project and file with no diagnostic.
"human"Enforces human spellings. Machine-only forms (ef, ef*, unint, intr) report EK3014.
"machine"Enforces machine spellings. Long forms (effect function, effect function*, uninterruptible, interruptible) report EK3014.
  • Any other value for vibe.syntax reports EK3007.
  • extends inherits vibe.syntax key-by-key, child winning over base (VIP-30).
  • CLI flag --syntax=both|human|machine overrides vibe.syntax for a single invocation (vibe --syntax=human --noEmit, vibe --syntax=machine). An invalid --syntax value exits with status 2 and an error message.

4. Lossless 2-way compiler conversion (vibe convert)

The native compiler provides a deterministic, AST-verified bidirectional converter between human and machine representations:

# Convert files or stdin to machine representation
vibe convert --to=machine src/app.vibe
vibe convert --to=machine --write src/
vibe convert --to=machine --check src/
vibe convert --to=machine --indent=0 src/app.vibe
 
# Convert back to human representation
vibe convert --to=human --write src/
vibe convert --to=human --check src/
 
# Pipe over stdin/stdout (for editors, hooks, or coding-agent tool bridges)
vibe convert --to=machine --stdin-filepath src/app.vibe < src/app.vibe

Conversion guarantees:

  1. Exact AST equivalence (SameProgram): Every conversion parses both input and output with the VibeLang parser and verifies via vibelangfmt.SameProgram(before, after) that the AST, every module body, and comment/JSDoc attachment are identical. If verification fails or the input has syntax errors, convert exits non-zero and writes nothing.
  2. Idempotence & round-trip stability:
    • convert(to=machine, convert(to=machine, s)) == convert(to=machine, s)
    • convert(to=human, convert(to=human, s)) == convert(to=human, s)
    • SameProgram(s, convert(to=human, convert(to=machine, s))) == nil
    • SameProgram(s, convert(to=machine, convert(to=human, s))) == nil
    • convert(to=machine, convert(to=human, m)) == m for every m = convert(to=machine, s): machine to human to machine is byte-identical.
    • convert(to=human, convert(to=machine, h)) == h for every h = convert(to=human, s): human to machine to human is byte-identical on every formatted human file.
    • convert(to=machine, convert(to=human, s)) == convert(to=machine, s): the machine form does not depend on the route.
    • The machine form carries every token, comment and line of the program, blank lines included, and the line ending of the file (LF or CRLF), so convert(to=human, convert(to=machine, s)) == convert(to=human, s). Only indentation and the spacing inside a line differ between the two forms.
  3. Byte-identical compilation: Compiling src and convert(to=machine, src) produces identical emitted JavaScript and .d.vibe.ts declarations (excluding source-map column/line mappings).
  4. Comment, JSDoc, string, template, regex, and module preservation: Token rewriting operates strictly on scanner/AST positions, never blind regexes, so literals, comments, directives (// @vibe, // @vibelang-diagnostics), and TypeScript module bodies remain intact.
  5. Formatting integration: vibe format --mode=machine and vibe format --mode=human delegate to the same bidirectional engine (human mode runs the repository's configured TypeScript formatter via dprint after expanding machine shorthands).

5. Diagnostic EK3014

CodeCategoryTriggerRepair
EK3014ErrorA machine-only form (ef, ef*, unint, intr) appears under vibe.syntax: "human", or a human-only long form (effect function, effect function*, uninterruptible, interruptible) that has a machine spelling (section 2) appears under vibe.syntax: "machine"Run vibe convert --to=human --write or vibe convert --to=machine --write, or set vibe.syntax to "both".

Example: one program, two lossless views

Human representation (86 o200k_base tokens):

// human.vibe
error NotFound { id: string }
 
effect function findName(id: string): string!NotFound {
  if (id === "1") return "Ada"
  throw new NotFound({ id })
}
 
export effect function run() {
  const found = findName("1") catch () => "Guest"
  const fallback = findName("99") catch () => "Guest"
  return { found, fallback }
}

Machine representation (69 o200k_base tokens, -19.8% vs human .vibe), as vibe convert --to=machine prints it:

// machine.vibe
error NotFound{id:string}
 
ef findName(id:string):string!NotFound{
 if(id==="1") return "Ada"
 throw new NotFound({id})
}
 
export ef run(){
 const found=findName("1") catch()=>"Guest"
 const fallback=findName("99") catch()=>"Guest"
 return{found,fallback}
}