Policies operate the warehouse, and an agent drives changes with user guidance.
Robots follow a policy to deliver orders and stock inventory, while an agent works on an improvement that the user requested in the sidebar.
A declarative policy language (WPL) runs a simulated robot warehouse, and an agent in a custom harness rewrites those same policy rules based on telemetry and natural-language requests, so the policy stays up to date.
The setup

A warehouse is a uniquely challenging and dynamic environment. Orders can change mid-process, batteries can run out on robots mid-delivery, and aisles can become blocked. All of this compounds, so purely static rules for keeping robots on track are always one step behind.
As with a team’s playbook, some tactics work better than others on any given day. In this open case study, we simulate such a system: a warehouse with robotic stock management, whose behavior is declared by a program in a domain-specific language.
The language
The language itself is the Warehouse Policy Language, or WPL for short. It’s declarative, which fits the need to describe when a rule should apply and what it should do when it does.
For example, when stock is coming in, at least one robot is empty, and that robot has enough charge to do the work, a rule may match to send it to pick up an item. A rule fires when its guard matches, and otherwise gives a chance for subsequent rules to apply.
The semantics are deliberately simple: given rules A, B, and C, in that order, evaluate them top-down and execute the first match. An AI agent can then watch a system running these rules and adapt them based on the telemetry it receives.
rule "recharge when low" when currentCharge() < 0.2 {
let dest : Maybe<Target> = nearestFreeCharger()
match dest {
none => {}
value(charger: Target) => { goTo(charger) }
}
}
rule "claim an order" when !hasOrder() and pendingOrderCount() > 0 {
let order : Maybe<Order> = getOrder()
match order {
none => { yield }
value(o: Order) => { claimOrder(o) }
}
}
default {
pickupIncomingDelivery()
}Every robot runs a clearly identifiable rule

What’s in the box
inventory — 9 parts- language
WPL
A declarative language for what to do, and when to do it. Rules execute when their guards match.
- paradigm
- declarative
- unit
- rule
- trigger
- guard conditions
languageWPL
Each rule pairs a guard with an action, and a default covers the fallback case when no rule applies. A robot’s label in the simulator also names the rule it’s running at any given moment, so behavior is easy to trace.
- language
Typed vocabulary
Every action and query a policy can use is declared in a WPL library with a static type. Values that might be missing are Maybe<T> and must be unwrapped before being used.
- vocabulary
- @Library file
- types
- static
- absence
- Maybe<T> + match
languageTyped vocabulary
The library is itself a WPL file of type and function signatures, so both the editor and the agent can link against the same declarations, with docs provided on hover. A call to something that’s undeclared, or a Maybe<T> used as if it were there, is caught during type checking. Should the library be insufficient, it can be extended and modified to better fit the capabilities of the underlying robots, without needing to modify the core language.
- agent
Harnessed AI
The agent runs in a custom harness for WPL. It acts only through the tools it’s given for working with WPL and the simulation, and for discovering docs incrementally.
- harness
- custom
- toolset
- deliberately small
- reach
- policy + simulation
agentHarnessed AI
The harness defines how the agent sees and interacts with its environment. Anything outside the tool layer is explicitly out of reach, which limits the agent to the policy and the simulation.
- agent
Tool layer
Seven orthogonal tools are provided to the agent. Together they cover everything the agent needs to do its work.
- read · write
- WPL
- check
- diagnostics
- summarize · query
- telemetry
- apply
- restart sim
- look up
- domain docs
agentTool layer
The agent reads and writes WPL, checks diagnostics, summarizes and queries telemetry, applies changes by restarting the simulation, and looks up domain documentation. These tools are only accessible on the harness server, and the client reaches that server through four actions: start, stop, get state, and subscribe. Small, focused tools instead of one broad one make it easier for the agent to pick the right tool, and simplify tracing later on.
- workflow
Live editing
Revised policies are applied to the running simulation and replayed on the same seed, so policy experiments are properly controlled for.
- apply
- one tool call
- replay
- deterministic seed
- delta
- policy alone
workflowLive editing
Replaying on the same seed means any difference in the results comes from the policy change itself. A real warehouse never runs the same day twice, but a deterministic simulation lets us repeat tests quickly and see how results pan out. This makes it much easier to evaluate candidate policies against known scenarios.
- workflow
Validated changes
Every change the agent makes is in WPL. This means all rules are validated, changes can be diffed rule by rule, and a user can review each one before it’s applied.
- validate
- diagnostics
- diff
- rule by rule
- review
- before apply
workflowValidated changes
The agent doesn’t operate the running system directly. It indirectly changes the system state by proposing policy rule changes, which are validated and shown before they are applied to the simulation.
- workflow
LSP in the loop
Diagnostics from the WPL language server are fed back to the agent while it works, so it can check its code before anything is applied.
- source
- WPL language server
- feedback
- diagnostics
- loop
- edit · check · fix
workflowLSP in the loop
The same language server that backs the editor also reports errors to the agent. The agent writes code, reads the diagnostics, and fixes its own mistakes before a human sees the change.
- system
Telemetry
The agent reads the running system: orders, battery health, throughput, congestion, and more. This, combined with replays on the same seed, allows the agent to assess system changes after adjusting the policy.
- orders
- done · expired
- battery
- avg · charging
- flow
- stored · inbound
- motion
- util · blocked
systemTelemetry
The agent reasons over measured numbers: orders done or expired, average and charging battery levels, stored and inbound stock, robot utilization and blockage.
- system
A* routing
Routes are computed lazily using A* at the moment they’re needed, and only recomputed when they have to be, for instance when a robot detects an obstacle such as another robot.
- search
- A*
- evaluation
- lazy
- recompute
- on obstacle
systemA* routing
Re-planning only when something changes, such as a blocked path, keeps routing cheap while robots still react to obstacles. The DSL is unaware of the underlying pathfinding logic, so it can be swapped out for a more realistic algorithm when desired.
DSL and AI, in perfect unison
Alone, the DSL is effective but slow to iterate on, and the AI is powerful but needs steering. By combining the benefits of the two, we get a system that is both trustworthy and self-guiding. A user can state their observations and intent, and the AI can proceed through a workflow to transform that into a new policy.
This lowers the learning curve typically associated with using a DSL, while still reaping its benefits.
The DSL’s structure is now leverage for an AI to help get work done better and faster.
The TypeFox Way
We dig into the problem before we solve it.
First we get to know you and what you expect. Then we take the time to understand your domain and what you actually need. We ask our questions early, because an answer up front saves expensive rework later.
We deliver a first result you can see.
Whether it’s a proof of concept or a first milestone, we go for something you can see running, and we deliver it fast. We work within your process, or propose one if you don’t have one yet. Either way, we take ownership of our work and keep the ball rolling.
We work side by side with you.
You talk directly to the engineers who do the work, with one stable contact and a whole team behind them. When things get demanding, we stay calm and focused. Mastering a hard situation together is often when a working relationship becomes a partnership.
We advise you honestly and build for the long run.
If something won’t work, you’ll hear it early, with an alternative. No compromise on quality: testing and paying down technical debt matter as much as the next feature. That’s how we earn your trust and keep it for years.
Make our expertise yours
Languages for your experts.
We design domain-specific languages and their tooling, from syntax and validation to code generation. Experts state what they mean, and the tooling checks it for them.
see language engineering (typefox.io)Software modernization.
We modernize business-critical software, at AI speed and with senior engineers in control. The old system stays live until the new one has proven it behaves the same.
see how we modernize (typefox.io)Custom software tools.
We build the custom tool for the part no standard software covers, shaped around how your team already works. It takes over one step at a time, alongside the systems you rely on.
explore custom tools (typefox.io)Your software, overhauled.
Years of rules, fixes and feedback are built into your system. We carry that knowledge into a clean state your team can maintain again, with the system live the whole way.
see how we overhaul (typefox.io)