Learn EnsuraScript
Welcome to the EnsuraScript learning path! This tutorial series will teach you everything you need to know to write powerful declarative system automation.
What You'll Learn
This tutorial is organized into progressive sections that build on each other:
Getting Started
Start here if you're new to EnsuraScript.
- Installation - Set up EnsuraScript on your system
- Your First Guarantee - Write and run your first EnsuraScript program
Core Concepts
Learn the fundamental building blocks of the language.
- Understanding Resources - Files, HTTP endpoints, and other system entities
- Writing Guarantees - The
ensurestatement and guarantee syntax - Using Handlers - Built-in handlers for encryption, permissions, and more
Advanced Features
Master the powerful features that make EnsuraScript unique.
- Creating Policies - Reusable guarantee templates with parameters
- Guards & Conditions - Conditional guarantees with
whenclauses - Dependencies - Ordering guarantees with
requires,after, andbefore - Collections & Invariants - Enforce guarantees across multiple resources
- Violation Handling - Retry logic and notifications when guarantees fail
Deep Dives
Understand how EnsuraScript works under the hood.
- Implication System - How guarantees automatically expand into prerequisites
- Execution Model - Topological sorting and continuous enforcement
Learning Path
We recommend following the tutorials in order, especially if you're new to declarative programming. Each tutorial builds on concepts from previous ones.
Not Just Another Scripting Language
EnsuraScript is fundamentally different from traditional automation tools. Instead of writing procedures (step-by-step instructions), you write guarantees (statements of truth). The runtime maintains those truths automatically through continuous monitoring and enforcement.
Quick Examples
Secure a File
on file "secrets.db" {
ensure exists
ensure encrypted with AES:256 key "env:SECRET_KEY"
ensure permissions with posix mode "0600"
}Monitor an API
on http "https://api.example.com/health" {
ensure reachable
ensure status_code with http.get expected_status "200"
ensure tls
}Create Reusable Policies
policy secure_file(key_ref) {
ensure encrypted with AES:256 key key_ref
ensure permissions with posix mode "0600"
}
on file "database.db" {
apply secure_file("env:DB_KEY")
}Ready to Start?
Begin with Installation to set up EnsuraScript on your system, then move on to Your First Guarantee to write your first program.
If you prefer to jump straight to specific topics, use the sidebar to navigate to any section.