Skip to content

Latest commit

 

History

History
80 lines (63 loc) · 3.2 KB

File metadata and controls

80 lines (63 loc) · 3.2 KB

.reson DSL Specification & Examples

The .reson Domain-Specific Language is a declarative, human-readable specification format for modeling discrete-time resource pools, state transitions, production lines, and supply chains.


1. Syntax & Core Primitives

A .reson file contains blocks of resource and process definitions. Indentation (tabs or 4 spaces) defines block hierarchy. Comments start with # or //.

1.1 Resource Atom

Represents state, inventory, working capital, or equipment capacity.

pencil_machine
    resource
    unit count
    amount 2
    max 5
    life 5 y
  • unit: Display unit string (e.g. count, kg, cad, kwh).
  • amount: Initial stock available at $T=0$.
  • max: Storage limit ceiling (optional).
  • life: Perishable lifespan (optional). Units: s (seconds), m (minutes), h (hours), d (days), w (weeks), y (years). Decays via a deterministic FIFO queue.

1.2 Process Atom

Represents a discrete transformation converting input resources into output resources.

manufacture_pencil
    process
    use
        wood 10
        graphite 2
        electric_intake 0.7
    produce
        pencil 10
    catalyze 2
        pencil_machine 1
    period 1 s
    duration 3 s
    priority 1
    constraint
        w 1-5
        h 8-17
  • use: Map of consumed resources and quantities per execution batch.
  • produce: Map of generated resources and quantities per execution batch.
  • catalyze [parallel_max]: Non-consumed equipment/labor required for the process to run. parallel_max defines maximum concurrent active batches.
  • period: Recurrence interval (e.g. 1 s, 30 m, 1 d).
  • duration: WIP incubation latency. Inputs are consumed immediately; outputs are committed when duration completes while locking required catalysts.
  • priority: Scheduling tier precedence (lower numbers evaluate first).
  • constraint: Operational time window filter:
    • w 1-5: Monday to Friday (1 = Monday, 7 = Sunday).
    • h 8-17: 8:00 AM to 5:00 PM.
  • on_use [max_count]: On-demand process triggered when downstream consumers request its product.

2. Built-in Industrial Models

Model File Domain Key Mechanics Demonstrated
simple_pencil.reson Manufacturing Equipment catalysts, reorder purchasing, multi-step assembly, sales cashflow.
food_factory.reson Food & Agriculture Multi-product batching (bread & cookies), perishable dough decay queues (life 4 h), oven catalysts.
semiconductor_fab.reson High-Tech Hardware Photolithography stepper locking, cleanroom utility usage, multi-output scrap defect distributions (wafer 85, defect 15).
ev_gigafactory.reson EV & Energy Storage Cathode slurry mixing, dry-room aging queues, electrode calender catalysts, assembly pacing.

3. Running an Example in CLI

cargo run --release -- reson_file=example/simple_pencil.reson start_time=1700000000 write_every=1 run_for=3600