Every developer has a horror story about a --dry-run flag.
You write a quick maintenance script to clean up old files or migrate local data. You carefully add a dry_run boolean variable, wrap your primary write function in an if not dry_run: block, and run it with confidence.
Then, three levels deep in an obscure helper function, a raw fs.unlink() or http.post() executes anyway because you forgot to wrap it. The script modifies state mid-rehearsal, leaving you with half-mutated data and a mild panic attack.
Hand-rolled dry-run flags fail because they rely on developer discipline. Rye fixes this by pushing dry-run execution down into the language runtime using two primitives: Landlock sandboxing and I/O Intents.
The Flaw in Traditional Dry-Runs
In standard scripting languages, opting into a dry run is purely conversational—you are asking the code to be polite:
# The standard, fragile approach
def cleanup(target_dir, dry_run=True):
for path in get_files(target_dir):
if dry_run:
print(f"Would delete: {path}")
else:
os.remove(path)
# Oops: a nested utility forgot to check the flag
write_audit_log(path) # Mutates state during a dry run!
If any dependency, C extension, or forgotten utility bypasses that conditional logic, side effects happen anyway.
Layer 1: Hardware-Enforced Boundaries (Landlock)
Instead of hoping your code honors a boolean flag, Rye lets you enforce filesystem restrictions at the OS kernel level using Linux Landlock.
When running in dry-run mode, you can physically lock down the filesystem. If a buggy function attempts an unauthorized write, the kernel rejects it—regardless of what the language code tried to do:
; Initialize the Landlock builder
ll: rye .Landlock
; Allow reading the current working directory, but block ALL writes
ll | landlock//Limit-to-cwd
ll | landlock//Enforce
; Any attempt to write past this point raises an immediate runtime error
write %/tmp/accidental-mutation.txt "data"
Because Landlock is enforced by the Linux kernel, it cannot be bypassed by third-party C libraries or nested helper functions. It turns soft dry-run promises into hard execution boundaries.
Layer 2: Intent-Based I/O
A dry run shouldn’t just block writes; it should show you exactly what it intended to do.
This is where Intents come in. Instead of executing I/O immediately, Rye lets you wrap side effects in structural intents. When --dry-run is active, the runtime logs the payload and bypasses execution automatically.
; Define an output-intent wrapper
output-intent: fn { meta blk } {
if rye .Is-dry-run {
print "DRY-RUN INTENT: " + (meta |to-json)
} else {
do blk
}
}
; Usage throughout your script
output-intent { action: "delete", target: "/tmp/old_cache.json" } {
delete %/tmp/old_cache.json
}
What happens when you run this?
- Live Mode (
rye script.rye): The metadata is ignored, the block executes, and/tmp/old_cache.jsonis deleted. - Dry-Run Mode (
rye --dry-run script.rye): The block is skipped, and the console displays a structured execution plan:
DRY-RUN INTENT: {"action":"delete","target":"/tmp/old_cache.json"}
Layer 3: Catching Network Leaks with Unshare
Filesystem writes are only half the problem. What if your script tries to trigger a Webhook or hit an external API during a dry run?
By pairing Landlock and Intents with Rye’s namespace isolation (--unshare), you can sever network access at startup:
# Run a dry-run rehearsal with zero network access and a jailed filesystem
rye --dry-run --unshare my-migration.rye
Inside the script, input intents can automatically serve local offline fixtures instead of hitting live endpoints:
fetch-schema: fn { } {
if rye .Is-unshare-net {
; Serve local fixture during offline dry-run
(intent.input.http "GET https://api.internal/schema")
} else {
http-get "https://api.internal/schema"
}
}
The Combined Workflow
When you combine these layers, dry runs stop being a scary roll of the dice and become a structured rehearsal.
; 1. Require unshared execution environment
rye .Require-unshared
; 2. Enforce strict filesystem rules (Read-only project root)
ll: rye .Landlock
ll | landlock//Limit-to-cwd
ll | landlock//Enforce
; 3. Execute script logic safely
output-intent { file: "report.json", action: "generate_summary" } {
write %report.json (to-json summary_data)
}
Rehearsal Over Guesswork
Dry runs shouldn’t depend on whether you remembered to wrap every file write in an if block.
By combining kernel-level sandboxing with explicit I/O intents, Rye makes dry-run execution deterministic and physically safe. You get a full, transparent audit log of every side effect your script wanted to perform—without risking your local environment in the process.