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:
- 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 from90.9%to40.9%. - 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-30corpus from4,688(human.vibe) to3,960(-15.5%vs human.vibe,-36.0%vs Effect 4 TS's6,183o200k_basetokens) at 1-space indentation — and3,822(-18.5%vs human.vibe,-38.2%vs Effect 4 TS) at 0-space indentation — verified30/30with the native VIP-82 compiler (30/30byte-identicalmachine → human → machineround trip,30/30byte-identical.d.tsdeclarations,30/30byte-identical JavaScript,30/30expected runtime output).node docs/user/benchmarks/agent-syntax/verify-machine-mode.mjs --writeregenerates these numbers (vip82MachineMode30Tasks).
Measuring candidate substitutions against o200k_base and cl100k_base shows why most Vibe keywords stay unchanged:
| Candidate substitution | Included? |
|---|---|
effect function / effect function* → ef / ef* | Yes (multi-token head → 1 token) |
uninterruptible / interruptible → unint / intr | Yes (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:
| Construct | Human form | Machine form | Spec chapter |
|---|---|---|---|
| Effect function declaration | effect function f(...) { ... } | ef f(...) { ... } | Functions |
| Exported effect function | export effect function f(...) | export ef f(...) | Functions |
| Effect producer declaration | effect function* f(...) { ... } | ef* f(...) { ... } | Functions |
| Exported effect producer | export effect function* f(...) | export ef* f(...) | Functions |
| Effect method / producer method | effect m(...) { ... } / effect* m(...) { ... } | ef m(...) { ... } / ef* m(...) { ... } | Functions |
| Interruption mask blocks | uninterruptible { ... } / interruptible { ... } | unint { ... } / intr { ... } | Running Effects |
| Layout & spacing | Standard repository formatter style (dprint / Prettier) | 1-space indent (or --indent=0) and BPE-tight punctuation spacing, on the same lines as the human form | Tooling |
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:
efstarts 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 beforeefhad a meaning. Ordinary identifiers and calls (const ef = 1,ef(x),obj.ef,class C { ef() {} }) keep their exact TypeScript meaning.unintandintrstart an interruption mask block only when followed by{on the same line (unint { ... },intr { ... }), following VIP-22'sisVibeLangMaskWordrule. Ordinary identifiers (const unint = true,intr(x)) keep their exact TypeScript meaning.- Both
efandeffect functionparse into the exact sameFunctionDeclaration(witheffectmodifier flag), andunint/intrparse into the exact same interruption block AST nodes asuninterruptible/interruptible. - Inside
module Name { ... }TypeScript bodies (VIP-40),ef,unint, andintrhave no special meaning and are never rewritten. - Where
efdoes not start a declaration, the long form is the only spelling in both forms: aneffect functionexpression (const f = effect function g() {}), a default export (export default effect function f() {}), an effect function namedas,satisfiesoris(afterefthese 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 betweeneffectandfunction(efhas no place to keep it), and a head with a line break betweeneffectand the name.vibe convert --to=machineleaves these unchanged, andvibe.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):
| Value | Behavior |
|---|---|
"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.syntaxreportsEK3007. extendsinheritsvibe.syntaxkey-by-key, child winning over base (VIP-30).- CLI flag
--syntax=both|human|machineoverridesvibe.syntaxfor a single invocation (vibe --syntax=human --noEmit,vibe --syntax=machine). An invalid--syntaxvalue exits with status2and 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.vibeConversion guarantees:
- Exact AST equivalence (
SameProgram): Every conversion parses both input and output with the VibeLang parser and verifies viavibelangfmt.SameProgram(before, after)that the AST, everymodulebody, and comment/JSDoc attachment are identical. If verification fails or the input has syntax errors,convertexits non-zero and writes nothing. - 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))) == nilSameProgram(s, convert(to=machine, convert(to=human, s))) == nilconvert(to=machine, convert(to=human, m)) == mfor everym = convert(to=machine, s): machine to human to machine is byte-identical.convert(to=human, convert(to=machine, h)) == hfor everyh = 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.
- Byte-identical compilation: Compiling
srcandconvert(to=machine, src)produces identical emitted JavaScript and.d.vibe.tsdeclarations (excluding source-map column/line mappings). - Comment, JSDoc, string, template, regex, and
modulepreservation: Token rewriting operates strictly on scanner/AST positions, never blind regexes, so literals, comments, directives (// @vibe,// @vibelang-diagnostics), and TypeScriptmodulebodies remain intact. - Formatting integration:
vibe format --mode=machineandvibe format --mode=humandelegate to the same bidirectional engine (humanmode runs the repository's configured TypeScript formatter viadprintafter expanding machine shorthands).
5. Diagnostic EK3014
| Code | Category | Trigger | Repair |
|---|---|---|---|
EK3014 | Error | A 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}
}