Skip to main content

Draton Analyst Artifact

This document is a compact analyst-facing artifact for reviewers, contributors, and tool builders who need the architectural truth quickly.

It is intentionally denser and more checklist-oriented than language-architecture.md.

Executive Summary

Draton is a readability-first, statically typed, tooling-first compiled language with a canonical syntax surface and an explicit contract layer.

Its architecture is built around:

  • one canonical executable surface
  • one canonical contract mechanism
  • one structural model based on class and layer
  • one authoritative implementation path in Rust

Architectural Identity

AreaDraton position
Primary goalReadable code with strong tooling
Execution modelCompiled to native code through LLVM
Typing modelStatic typing with inference by default
Contract modelExplicit @type blocks
Structural modelclass for structure, layer for capability grouping
Control flowExplicit return remains canonical
Import modelimport { item } from module.path
Tooling stanceIntegrated drat toolchain is first-class
Compatibility stanceMigration support only, not co-equal design

Canonical Language Invariants

These invariants define the language architecture:

  1. Code expresses behavior.
  2. @type expresses contracts.
  3. let is the canonical binding form.
  4. return remains explicit.
  5. Brace imports remain canonical.
  6. class models structure.
  7. layer models grouped capability.
  8. Compatibility syntax does not define a second language philosophy.

What The Language Optimizes For

Draton is optimized for:

  • codebases that need strong tooling
  • compiler and language-engineering work
  • explicit, maintainable source structure
  • projects that want inference by default and contracts when needed

It is not optimized for:

  • multiple equally valid syntax dialects
  • maximal terseness
  • inline type density as a default experience
  • reopening settled canonical syntax questions

Separation Of Concerns

ConcernArchitectural home
Runtime behaviorexecutable code
Type intent@type blocks
Structural organizationclass, layer, file/module layout
Native executionLLVM + runtime
User workflowdrat CLI
Editor supportdraton-lsp

Syntax Architecture Snapshot

TopicCanonicalNot canonical
Bindingslet x = 1let x: Int = 1
Functionsfn f(a) { return a }fn f(a: Int) -> Int { ... }
Contracts@type { f: (Int) -> Int }inline type noise as default
Importsimport { x } from pkg.modalternate primary import dialects
Control flowexplicit returnimplicit-return-only philosophy

Semantic Layering

The language can be understood in three layers:

Layer 1: executable surface

  • expressions
  • statements
  • function bodies
  • class/layer member behavior

Layer 2: contract surface

  • file/class/layer/interface/function @type
  • interface member contracts
  • explicit hints where inference needs help

Layer 3: implementation substrate

  • Rust frontend
  • LLVM backend
  • Draton runtime
  • self-host mirror for parity and long-term self-hosting

Implementation Truth Table

ConcernSource of truth
Canonical syntaxRust parser + docs
Type contract semanticsRust typechecker + docs
Native codegen semanticsRust codegen + runtime
Self-host behaviorMust preserve Rust parity
Policy and anti-driftAGENTS + architecture/rules docs

Current Repository State

As of the current repository state:

  • canonical syntax is stabilized
  • strict syntax mode exists
  • executable/compiler-path self-host migration is effectively complete
  • only two deferred non-executable dump/printer files remain outside full-tree strict self-host coverage:
    • src/ast/dump.dt
    • src/typeck/dump.dt
  • the self-host bootstrap path is still tracked separately because drat build src/main.dt can hit LLVM ERROR: unknown special variable

Implications For Reviewers And Contributors

When evaluating a change, ask:

  1. Does it preserve readability-first source?
  2. Does it keep contracts in @type rather than pushing types back inline?
  3. Does it preserve the class / layer model?
  4. Does it keep docs, parser behavior, and examples aligned?
  5. Does it maintain Rust frontend authority and self-host parity?

If the answer to any of those is "no", the default position should be to reject or narrow the change.

Quick Component Map

ComponentRole
draton-lexertokenization
draton-astshared syntax tree model
draton-parsergrammar and AST construction
draton-typeckinference and contract checking
draton-codegenLLVM lowering
draton-runtimeGC, safepoints, scheduler, runtime ABI
draton-stdlibhost-side standard library
draton-lspeditor protocol support
dratunified CLI and tool hub
src/self-host mirror of compiler layers

For architecture review:

  1. language-manifesto.md
  2. language-architecture.md
  3. language-class-diagram.md
  4. compiler-architecture.md
  5. canonical-syntax-rules.md
  6. contributor-language-rules.md
  7. selfhost-canonical-migration-status.md