Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
77794dc
feat(lean): experimental alchemy-lean and alchemy-bend prototypes
sam-goodwin Nov 23, 2026
6ef74f7
feat(lean): Effect, services and Layers
sam-goodwin Nov 24, 2026
86b1c86
feat(lean): errors as data types, raised through Layers
sam-goodwin Nov 24, 2026
6767e26
feat(lean): build a Layer's services in a do block
sam-goodwin Nov 24, 2026
6d3b2e9
feat(lean): host a domain model on a stack
sam-goodwin Nov 24, 2026
d6dc589
feat(lean): bindings and consumers as steps of a Worker's block
sam-goodwin Nov 24, 2026
f3d0fa8
feat(lean): least privilege as a theorem, proved from stories
sam-goodwin Nov 24, 2026
2df010b
feat(lean): a view and a projection in the Shop example, with proofs
sam-goodwin Nov 24, 2026
f8ddb37
feat(lean): hosting proof, block-style Lambda functions, access and a…
sam-goodwin Nov 24, 2026
583bc3e
feat(lean): model syntax, with views and projections that come with t…
sam-goodwin Nov 24, 2026
158341f
feat(lean): generated served model and lifted rules, stack outputs, s…
sam-goodwin Nov 24, 2026
07f5050
feat(lean): laws for bindings, and the hosting code proved from them
sam-goodwin Nov 24, 2026
72acceb
feat(lean): behaviour theorems for every order in the Shop example
sam-goodwin Nov 24, 2026
8856428
feat(lean): a bank example built from behaviour, invariants and their…
sam-goodwin Nov 24, 2026
1215d8f
feat(lean): decisions and sagas in the model syntax, linked models, a…
sam-goodwin Nov 24, 2026
194d5ff
feat(lean): a payout saga in the bank, and the bank linked to a compl…
sam-goodwin Nov 24, 2026
5e13777
feat(lean): behaviour theorems across policies, sagas and linked models
sam-goodwin Nov 24, 2026
c6b30ed
feat(lean): one scenario as a story, a theorem, and the story as the …
sam-goodwin Nov 24, 2026
9b8808b
feat(lean): a story follows a shared scenario
sam-goodwin Nov 24, 2026
343e62b
feat(lean): access rules stated in the stack's own words
sam-goodwin Nov 24, 2026
393e4f3
feat(lean): behaviour of the Api for every request, from the binding …
sam-goodwin Nov 24, 2026
41d69c9
docs(lean): rewrite the README for the current DX
sam-goodwin Nov 24, 2026
d25560a
docs(lean): README as code with a line or two per snippet
sam-goodwin Nov 24, 2026
d35a9b7
feat(lean): run a stack from the command line to see its graph and plan
sam-goodwin Nov 24, 2026
ba4d162
feat(lean): a function's role read off the calls in its block
sam-goodwin Nov 24, 2026
dfdfd6a
feat(lean): direct calls everywhere on AWS, least privilege read off …
sam-goodwin Nov 24, 2026
ca9574d
refactor(lean): say who answers the shop's outside calls where it is …
sam-goodwin Nov 24, 2026
4f6b54f
refactor(lean): call tests of a stack tests, not stories
sam-goodwin Nov 24, 2026
5bfa5bb
feat(lean): tell a domain story to the deployed stack
sam-goodwin Nov 24, 2026
98d18f0
feat(lean): an aggregate block, with reply
sam-goodwin Nov 24, 2026
a6c93d3
feat(lean): a second aggregate in the Shop, told by a policy on the f…
sam-goodwin Nov 24, 2026
88d120b
feat(lean): idempotent and commuting commands, as general properties
sam-goodwin Nov 24, 2026
93e78b3
feat(lean): each command declares the events and rejections it can gi…
sam-goodwin Nov 24, 2026
bb43743
docs(lean): a step-by-step guide
sam-goodwin Nov 24, 2026
432426b
docs(lean): explain why the access proofs matter, with a change that …
sam-goodwin Nov 24, 2026
7f8e43d
docs(lean): ground the access proofs in the system of record and cust…
sam-goodwin Nov 24, 2026
ce5241e
docs(lean): drop the unused-permissions theorem from the examples; it…
sam-goodwin Nov 24, 2026
f67fcc4
feat(lean): an upload-scanning stack whose safety is proved from who …
sam-goodwin Nov 24, 2026
72392e7
feat(lean): no infected file is ever published, proved over every sta…
sam-goodwin Nov 24, 2026
5691457
feat(lean): helper functions whose grants are read off their bodies
sam-goodwin Nov 24, 2026
ca4599b
fix(lean): behaviour settles branches by arithmetic, readable stack_r…
sam-goodwin Nov 24, 2026
c6a694d
feat(lean): a hosted function answers with the command's reply
sam-goodwin Nov 24, 2026
09806bc
feat(lean): the upload proof is tied to the deployed Scanner's code b…
sam-goodwin Nov 24, 2026
f57871d
feat(lean): stack_rule finds the stack's outputs itself
sam-goodwin Nov 24, 2026
00eef61
feat(lean): aggregate_rule and command_law read their names off the goal
sam-goodwin Nov 24, 2026
51fc1de
feat(lean): --why points at the call inside a helper
sam-goodwin Nov 24, 2026
b189e75
feat(lean): a hosted model takes decisions, and plain messages for a …
sam-goodwin Nov 24, 2026
ff9bd58
feat(lean): Cloudflare Workers read their bindings off their calls
sam-goodwin Nov 24, 2026
e819238
refactor(lean): remove binding steps for hosts
sam-goodwin Nov 24, 2026
fc34e59
refactor(lean): one way to state access rules; a check that the docs …
sam-goodwin Nov 24, 2026
52bc069
feat(lean): a plan shows which settings change
sam-goodwin Nov 24, 2026
3fa83ee
fix(lean): import the command line in the AWS control module
sam-goodwin Nov 24, 2026
a201e0a
feat(lean): a view with a value for each instance
sam-goodwin Nov 24, 2026
fccb1e7
feat(lean): laws for the Cloudflare operations, and a proof about the…
sam-goodwin Nov 24, 2026
a56b6a8
feat(lean): a journal's text form is proved to read back, so the requ…
sam-goodwin Nov 24, 2026
df6c7a0
feat(lean): a helper's requirements as one named requirement
sam-goodwin Nov 24, 2026
f1f392c
feat(lean): an aggregate can say who sends its commands
sam-goodwin Nov 24, 2026
1c41146
feat(lean): streams and queries in the model block
sam-goodwin Nov 24, 2026
51df0ac
docs(lean): keep the README in step with the linked example
sam-goodwin Nov 24, 2026
b881527
feat(lean): several sagas in one model, each with its own types
sam-goodwin Nov 24, 2026
988dae3
feat(lean): a network of any number of models
sam-goodwin Nov 24, 2026
3dc8df2
fix(lean): state what the three linked models actually do on a refuse…
sam-goodwin Nov 24, 2026
04d92d7
feat(lean): eventually, with a measure that shows a model comes to rest
sam-goodwin Nov 24, 2026
8a9ae25
feat(lean): a Cloudflare control plane, so its stacks plan and deploy…
sam-goodwin Nov 24, 2026
409798e
feat(lean): a network's run is within what it can reach, whatever ord…
sam-goodwin Nov 24, 2026
f0c6f77
feat(lean): an aggregate can name its instances by any type
sam-goodwin Nov 24, 2026
e3081b9
feat(lean): the Cloudflare control plane can refuse, and its provider…
sam-goodwin Nov 24, 2026
3020d91
feat(lean): a model with calm policies comes to rest from any world i…
sam-goodwin Nov 24, 2026
cfa63d9
feat(lean): a model with sagas comes to rest from any world it can reach
sam-goodwin Nov 24, 2026
b9aff16
feat(lean): every allowed move stays within what a model, or a networ…
sam-goodwin Nov 24, 2026
9cd375c
feat(lean): one story told to the model and to the stack; the POST ro…
sam-goodwin Nov 24, 2026
e47575c
feat(lean): comes_to_rest finds the weights itself; Wallet uses the a…
sam-goodwin Nov 24, 2026
97d6fd6
feat(lean): comes_to_rest measures ranks in one pass, gives the step …
sam-goodwin Nov 24, 2026
003bd41
refactor(lean): helper becomes effect def
sam-goodwin Nov 24, 2026
296e1b7
feat(lean): layers that ask for their dependencies, provided once whe…
sam-goodwin Nov 24, 2026
b36fd3f
feat(lean): the engine on stores, with a law per service and one refi…
sam-goodwin Nov 24, 2026
3be8dd8
feat(lean): what is read is kept up as events are delivered, and agre…
sam-goodwin Nov 24, 2026
c68fa26
feat(lean): stored views agree with the views the model computes
sam-goodwin Nov 24, 2026
cd0cfda
feat(lean): model generates its stored form: plain policies, stored v…
sam-goodwin Nov 24, 2026
e524f4b
feat(lean): the shop kept in stores: one theorem for any lawful services
sam-goodwin Nov 24, 2026
ac59f90
feat(lean): history theorems: tallies, precedence within an instance,…
sam-goodwin Nov 24, 2026
dfd976b
feat(lean): internal aggregates, and a theorem for events that need a…
sam-goodwin Nov 24, 2026
8d5eaca
feat(lean): caused_by proves nothing ships unless it was paid
sam-goodwin Nov 24, 2026
10fdc7f
docs(lean): history, internal aggregates, stores and layers
sam-goodwin Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/alchemy-bend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/build
*.journal
5 changes: 5 additions & 0 deletions packages/alchemy-bend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build/
*.journal
.wrangler/
examples/bank/durable-object/Server.mjs
!examples/bank/clock.js
23 changes: 23 additions & 0 deletions packages/alchemy-bend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# The bank server: compiled by Bend to JavaScript, run by bun.
#
# docker build -t bend-bank . && docker run -p 8788:8788 -v bank:/data bend-bank
FROM debian:bookworm-slim AS build
RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://bend-lang.com/install.sh | sh
WORKDIR /src
COPY Domain.bend Model.bend ./
COPY examples ./examples
RUN cd examples/bank && BEND_NO_TELEMETRY=1 /root/.bend/bin/bend Server.bend -o /bank.js \
&& mv /bank.js /bank.cjs

FROM oven/bun:1-slim
# curl is how the server calls the outside systems at FRAUD_URL and PAYMENTS_URL.
RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /bank.cjs /app/bank.cjs
ENV BANK_HOST=0.0.0.0
WORKDIR /data
VOLUME /data
EXPOSE 8788
CMD ["bun", "/app/bank.cjs"]
55 changes: 55 additions & 0 deletions packages/alchemy-bend/Domain.bend
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# alchemy-bend: the pieces every aggregate shares.
#
# An aggregate is a module with a state, a command, an event and a rejection
# type, and two functions. decide answers a command with the events it
# records or a rejection, given a context (who asks, and when). evolve
# applies one event to the state. The templates here take those two
# functions and give back the rest.

import Base

# What decide answers.
type Decided<-E: Data, -R: Data> is Data:
Reject{why: R}
Record{events: +List<E>}

# A command with the context it is sent in.
type Sent<-X: Data, -C: Data> is Data:
Sent{context: X, command: C}

# The state after every event, in order, all recorded in one context.
def apply(~X: Data, ~S: Data, ~E: Data, ~evolve: X -> S -> E -> S, events: +List<E>, +context: X, state: S) -> S:
match events:
case Nil{}:
state
case e <> es:
apply(~X, ~S, ~E, ~evolve, es, context, evolve(context, state, e))

# The state a decision leaves: unchanged when the command is rejected.
def settle(~X: Data, ~S: Data, ~E: Data, ~R: Data, ~evolve: X -> S -> E -> S, +context: X, +state: S, decided: Decided<E, R>) -> S:
match decided:
case Reject{why}:
state
case Record{events}:
apply(~X, ~S, ~E, ~evolve, events, context, state)

# The state after one command.
def step(
~X: Data, ~S: Data, ~C: Data, ~E: Data, ~R: Data,
~decide: X -> S -> C -> Decided<E, R>, ~evolve: X -> S -> E -> S,
+context: X, +state: S, command: C
) -> S:
settle(~X, ~S, ~E, ~R, ~evolve, context, state, decide(context, state, command))

# The state after every command, in order.
def replay(
~X: Data, ~S: Data, ~C: Data, ~E: Data, ~R: Data,
~decide: X -> S -> C -> Decided<E, R>, ~evolve: X -> S -> E -> S,
commands: List<Sent<X, C>>, +state: S
) -> S:
match commands:
case Nil{}:
state
case Sent{+context, command} <> rest:
replay(~X, ~S, ~C, ~E, ~R, ~decide, ~evolve, rest,
step(~X, ~S, ~C, ~E, ~R, ~decide, ~evolve, context, state, command))
Loading
Loading