Parallelize more with BlockLease

Parallelize more with BlockLease

BackerLeader ●2 ●13 ●52
calendar_today • schedule2 min read

One of the ideas in the scrml compiler that I am excited about, is something I call "BlockLease."

Safe parallelism in agentic code work forces concurrency to be locked to files. Two agents editing the same file just leads to re-creating every atomics problem devs have ever faced.

The design of this idea still has open questions. if you have any thoughts, drop me a line.

The problem

Parallel coding agents are kept safe by file. Each gets its own git worktree, and no two are sent to the same file. That gives up the common case: two agents editing different functions in the same module. In scrml it cost real time — two agents both edited emit-logic.ts, one landed a whole-file copy, and the other's work was silently reverted. The edits never overlapped. The isolation unit was just bigger than the work.

The idea

"if every block of code gets a unique ID... parallelism is no longer locked to disjoint files but to disjoint blocks... attach to blocks, no one else can edit those blocks..."

A block is a named definition — function, component, engine, type, channel — with the ID <relpath>::<name>. The ID already existed as a provenance anchor; block-lease reuses it as a concurrency token. One ID system, two jobs.

Block boundaries come from the compiler, not a separate parser. If two parsers disagree about where a block ends, two agents can each believe they hold the same lines. An early regex version assigned a four-line helper over 100 lines because a page's render markup followed it.

Admission is not landing

A lease decides whether two edits may proceed in parallel. It does not merge them, and text-disjoint is not the same as safe. Two branches can each add a write to errorMessage in different functions, merge without a conflict, and break the program.

What the compiler provides

scrml compile --emit-block-analysis writes each block's span and the cells it reads and writes:

${
  <errorMessage> = ""
  <okCount> = 0
  <quoteForm> = { originCity: "", weightLbs: 0 }

  function setError(m) { @errorMessage = m }
  function handler1() {
    @okCount = @okCount + 1
    setError("x")
  }
  function setCity(c)   { @quoteForm.originCity = c }
  function setWeight(w) { @quoteForm.weightLbs = w }
}
{ "id": "app.scrml::setError",  "reads": [],          "writes": ["errorMessage"] }
{ "id": "app.scrml::handler1",  "reads": ["okCount"], "writes": ["okCount"] }
{ "id": "app.scrml::setCity",   "reads": [],          "writes": ["quoteForm.originCity"] }
{ "id": "app.scrml::setWeight", "reads": [],          "writes": ["quoteForm.weightLbs"] }

Footprints are at field grain: setCity and setWeight write different fields of quoteForm and do not conflict.

They are also shallow. handler1 calls setError, which writes errorMessage, but handler1's footprint says only okCount. A non-empty footprint can still be incomplete. Until the compiler reports what a block writes through its calls, a sound check must reject any block that calls a helper — and most real handlers do.

Where it stands

Built: compiler-defined block identity and spans, field-grain read/write footprints, and a structured merge in giti that consumes them. Not built: the claim/release lease registry, leasing of render markup, and transitive footprints — the piece the rest waits on.

"scrml has subsumed block-lease"

What conflicts is not files but what an edit reads and writes. The compiler is the one component that knows that, so it is the one that has to answer.

🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

A Textile Mill's Dyehouse Ramp Curve: Get One Step Wrong and the Sheet Belongs to the Master

aiomniu - Oct 18

While my keyboard gently weeps.

Bryan MacLeeverified - Oct 31

Go type yourself!

Bryan MacLeeverified - Oct 30

Markdown without a back door: <md>

Bryan MacLeeverified - Oct 27

Is there any way to make type conversion sexy? Nope

Bryan MacLeeverified - Oct 20
chevron_left
4.1k Points • 67 Badges
Vernal UT • scrml.dev
19Posts
42Comments
58Connections
I am a truck drive specializing in the oil and gas industry, who happens to love coding.
i have been... Show more

Related Jobs

View all jobs →

Commenters (This Week)

6 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!