Wagoe 1.1 — enforced Functional Core / Imperative Shell across 28 libraries

I’ve been building a batteries-included Clojure framework for a couple of years. 1.0 landed end of September, 1.1 three weeks ago. I’d rather use this thread for the argument than the announcement, because the argument is the part I can’t settle on my own.

What it is, briefly

28 libraries across foundation, application and extension tiers, plus five developer tools — 33 artifacts under com.wagoe, all on one version. Every module has the same four-part shape:

{module}/
├── core/       ; pure functions. no I/O, no logging, no exceptions
├── shell/      ; side effects: persistence, services, HTTP
├── ports.clj   ; protocols, the contract between the two
└── schema.clj  ; Malli

core never touches shell. Functional Core / Imperative Shell — Bernhardt and Cockburn got there long before I did. The part that’s mine, and the part I’d like picked apart, is that Wagoe doesn’t document that rule. It enforces it. Import a database or logging namespace into core/ and the build fails.

1.1 is the authorization release: permissions, roles and scopes that modules declare, groups hold and routes check. What I spent the time on isn’t the enforcing but the answering — pick a user and a permission and the admin says yes or no and which group made it so; change a group and you see who gains and loses what before anything is written. New apps enforce from the first run, existing apps stay :off until you flip it.

Because the module shape is predictable, scaffolding from a sentence works well enough to put on stage: bb scaffold ai "invoice module: number, customer, line items, total in cents, due date, status draft→sent→paid"produces the schema, the pure core, a ports protocol, an adapter, handlers and tests, wired into Integrant. I put it this way at the Conj: the agent didn’t get smarter, the framework stopped asking it to guess.

The objection I want to hear properly

The strongest case against this is one I find genuinely hard to answer.

Clojure’s ecosystem works because nobody owns the seams. You compose what you need, you swap a piece when it stops fitting, and a bad decision stays local. A framework moves those decisions up a level and makes them mine. When my abstraction is wrong for your case you don’t swap a library — you fight the thing that generated your module. Twenty-eight libraries on one version number is twenty-eight places where that can happen at once.

My answer is that the real choice isn’t framework vs. no framework but explicit conventions vs. implicit ones: every serious Clojure backend already has conventions, usually undocumented, usually living in one or two people’s heads. But that’s a comfortable answer coming from the person who spent two years building the framework, so I’d rather hear where it breaks than defend it.

What I’d actually like to know

Three questions, ordered by how much your answer would change what I do next.

  1. If you have a Clojure codebase where the architecture lives in one or two people’s heads: would an enforced core/shell split have saved you wiring, or added ceremony around problems you didn’t have?
  2. Where does the enforcement become wrong rather than merely annoying? I know of one — a core function that legitimately wants to log. I’d like to know what else I’m going to hit.
  3. If you’ve built on Kit, Luminus, Duct or Biff and moved off: what made you leave? I’d rather learn that from you than from my own guesses.

The honest part

Solo project. Bus factor one. The community starts now.

Eight of the 28 libraries — config, ai, geo, external, reports, audience, webhooks and workflow — are marked incubating and sit outside the SemVer promise, with the reason per library on the stability page. payments graduated in 1.1; webhooks is new and took its place.

And the thing I’d rather tell you than have you find: 1.1.0, the authorization release, shipped with an access-control bug in its own admin. List pages let you filter and sort on fields the entity hides, so someone allowed to read users could recover password hashes and MFA secrets a character at a time. Fixed the next day in 1.1.1 — advisory GHSA-g896-jm3g-34h6. CI now opens every page of a freshly generated app on SQLite, PostgreSQL and MySQL, so that class fails the build. I’d rather you weigh the framework knowing that happened.

If you’re building something you’ll throw away in six months, Wagoe is more than you need.

Links

For 3 (not quoted). the closest I’ve gotten is Polylith (which I love now, but hated at first). It supports FCIS but doesn’t enforce it (there’s an article out here showing hexagonal architecture with Polylith). I really don’t like the other frameworks you mentioned (and don’t generally like any frameworks), because they are so opinionated.

For 1. I don’t know. We have a very CRUD-adjacent system at work. There’s are some pools of pure functional business logic but mostly it’s CRUD. I’ve always felt a strict enforcement would be painful. Creating an abstraction to turn all database operations into (polymorphic) parameters would be nearly impossible (we tried: it turned into horribly monadic-shaped code). And we interact will a lot of 3rd party services that are inherently “shell” in FCIS. We never even attempted to push those to FCIS.

For 2. I think logging would be the biggest obstacle since you usually want that as a macro that can capture file/line and maybe form – and you can’t pass macros around. I’d also perhaps argue that logging isn’t really IS since it doesn’t impact the result or any meaningful state of the world. It records information completely externally as a side-effect: the application doesn’t care about the logs. I actually think a lot of append-only database writes fall into that category too. Beyond that, I think it gets a bit of a grey area.

Thanks, this is more than I asked for.

The logging point is the one I’ll be chewing on. I’ve been splitting on “does this touch the world”. You’re saying it should be “does the computation depend on what comes back”. Those give different answers and yours is the better line.

Taking it seriously, the test becomes: can this fail silently without changing what the program concluded? Logging passes. If the write is lost, the decision was still right. Metrics pass. Most append-only writes too, though I’d separate an event log nobody reads back from an audit record that exists to be read back in a dispute. The second can’t fail silently, so it stays in the shell. Wagoe’s own rights timeline sits in that second group, which is a useful thing to notice about my own code.

That makes the logging exception a rule instead of a carve-out, which is what I should have had.

The macro half I have no answer to. If you want file and line you need the call site, and a call site can’t come through a port.

You’re right about the CRUD case and I wouldn’t argue it. What I would want to be clear about is that Wagoe doesn’t attempt what you tried. It doesn’t parameterise database operations or thread effects through pure functions, so the monadic shape shouldn’t turn up. Core returns decisions, the shell does the talking, ports sit between them. Third-party services are shell and I’ve never counted that as a compromise. For a system shaped like yours I suspect the generated admin would be worth more than the architecture.

Polylith is the comparison I should have been drawing and wasn’t. It splits physically, components behind interfaces, where this splits layers inside a module. Reads as orthogonal to me. I’d expect them to compose rather than compete.

What flipped for you on it? “Hated it, then loved it” is the interesting part. If it was that the structure stops feeling arbitrary once a team has turned over, that’s the same bet I’m making and I’d like to know it held. If it was something else, I’m probably over-weighting enforcement.

And “so opinionated” lands here too. The difference I’d claim is that the opinions are checkable rather than implied, but that defends how they’re stated, not having them.

A correction to my last reply, now that I’ve written it down properly.

I let “an event log nobody reads back” pass the test. I ended up drawing the line tighter: if it lands in the app’s own database, it stays in the shell, read back or not. “Nobody reads it” is true until someone adds a reader, and adding one shouldn’t silently move existing code across the line. Logs, metrics and traces still pass, because the application has no way to read them at all.

I hit that case while settling it. The rights timeline I mentioned reads from our audit log, and those audit writes were still best-effort from before the timeline existed. A failed write meant a gap in someone’s permission history. They’re now in the same transaction as the change.

And “a rule instead of a carve-out” was ahead of the code: core still doesn’t log. The rule is the reason now, not I/O. What’s missing is a way in that can’t affect the result, and your macro point is still where that gets stuck.

Agreed.

We generated a lot of our admin app from the database, first time around. Over time, we found we needed more and more custom logic around it, and gradually rewrote the generated version into a much more bespoke app (the generated version was actually ColdFusion-based, and then we rewrote it into Clojure over about a decade).

Part of my struggle—for our specific platform—is that many operations would have to go back and forth between “shell” and “core”: we’d do some CRUD stuff, some domain logic, some 3rd party service stuff, some more domain logic, then more CRUD, etc., etc. Pushing that domain logic into a separate “core” creates a lot of fragmented flows: it’s often been easier just to keep it all in the “shell” (essentially: it isn’t a separation we really follow). That’s especially true around the search engine machinery (an online dating platform is heavy on searching for matching profiles).

Yup, it was exactly that: Polylith’s rules around bases vs components vs projects and the strict separation of components into interfaces and implementations felt like a lot of ceremony/boilerplate when we got started, and the flattening of all the code into prefix.component.interface (and .impl) seemed a bit overwhelming as the number of components grew. Previously, we had some pretty deep ns naming so the top-level structure looked simpler…

…but of course that was just like a swan: graceful on the surface, but swimming like crazy under the water :slight_smile: At some point, we began to really value the focus on small, self-contained components and it made us think harder about naming and about dependencies.

The swan is a good description of my own first reaction too. Thanks for spelling out the flip, that’s not something you can tell from the outside.

The admin story is the one I’ll take to heart. Generated first, custom logic piling up, then rewritten by hand over a decade: that’s the path I’m worried about for Wagoe’s admin. What I’m aiming for next is that everything the generated admin does is also reachable through a port and a JSON API, so you can replace one screen with your own without losing what’s underneath, and the rewrite happens a piece at a time instead of all at once. Whether that holds up is the kind of thing I won’t know until someone has lived with it for a few years.

The back-and-forth flows are the strongest argument against what I’m doing, and I don’t think there’s a clean answer. When every step needs something the previous step decided and then fetched, you either split the flow into many small pure decisions with I/O between them, which is the fragmentation you describe, or you leave it in the shell. Wagoe doesn’t stop you from doing the second. The bet is narrower than it sounds: that the decision points are worth pulling out even when the orchestration stays imperative, because those are the parts you want to test without a database. For profile matching I’d guess the scoring is pure and everything around it isn’t.

Out of curiosity, on the matching side: is the scoring something you test in isolation, or is it tangled up with the search engine enough that it only really runs against an index?

Agreed. We rewrote initially from the bottom up: I built a ColdFusion/Clojure bridge (since CF runs on the JVM, this was mostly just plumbing “structs” to namespaces and “missingMethod” calls to Clojure functions), and started to replace low-level pieces first, then I built a CF web request/Ring bridge and replaced handlers one at a time, then finally I replaced the views themselves, one at a time. We joked about it being like rebuilding a 747 while it was flying!

Ah, okay. I’d love to find a clean way to separate things out in these places—and I’ve tried a few times but never been happy with the result. I think we’d end up fighting Wagoe for several of our apps (but maybe not all?). We kind of have to test with a real database and real local Elastic Search (and Redis) because of the woven flows that need to be tested: the logic fragments are small, and the state dependencies are strong.

To some extent, yes. Mostly what is pure is how we map from profiles to search queries, and how we map from user-friendly criteria to search queries. We also have a business-facing DSL based on the domain that can map to search queries, database queries (via HoneySQL), and Clojure predicate functions, so that can all be tested separately. But there are also tests directly against a real search index, because we’ve essentially built on own fuzzy matching on top of Elastic Search and we need to verify that behaves “as expected” for certain queries against certain index contents. That part is kind of our “secret sauce” after we moved away from a very expensive, proprietary fuzzy search engine (that had originally been developed for the real estate market, strangely enough).

That’s a good order to steal. Wagoe 1.2 is meant to be about adopting one library into an existing app without taking the rest, and bottom-up, then handlers, then views is roughly the path I want that to support. The 747 line is going to stay with me.

Fair on fighting Wagoe. If the fragments are small and the state dependencies are strong, forcing them into a core/shell split costs more than it gives. I’d rather say that plainly than pretend it fits everything.

The DSL is the part I find most interesting. One domain description with three interpretations: search query, HoneySQL and predicate. Do you check that they agree with each other, say by generating criteria and comparing what the predicate accepts with what the SQL returns? Or does each target get its own tests?

Yes, allowing for our deliberate fuzzing in the search queries, we test that what the SQL returns against our test dataset is also part of the search results and that all those profiles pass the predicate. A lot of that work was test-driven from the get-go.

We’ve also exposed that “sanity check” in the admin app, where the business folks can write the DSL to attach searches to pages, to create rules for profiles to test at login (where we might send certain members discount codes), and to produce segments of our members for campaigns or other promotional or analysis purposes. When one of the business folks edits a DSL rule, we run a search query and a SQL query and show them the top results, and they can enter a list of profile IDs to verify the predicate as well.

That’s a nice invariant. Allowing for the fuzz, the SQL results are a subset of the search results and everything passes the predicate. Containment instead of equality is a clean way to keep the fuzzing from making the check useless.

Putting the same check in front of the business folks is the part I hadn’t thought of. A rule editor that shows what each interpretation returns before you save turns a test into a feature. Wagoe has an incubating audience library for segments, and that idea is going straight into my notes for it.

Thanks for taking the time on all of this. It’s been the most useful conversation I’ve had since the release.

1 Like

I think this forum has a policy against posting LLM generated text. (And wow is this ever Claude flavored prose!)

My bad, I used Claude to reformulate my ideas and answers and will refrain from using it here from now on. Sean, our conversation was real and I really value your input and will certainly use it.