For IT teams that want the speed and simplicity of AI, with enterprise-class governance:
GenAI-Logic creates extensible projects for database transaction systems from your requirements. The AI is guided to write rules first, code only where needed: no-bypass logic you can read, trust and maintain.
Rules are readable: complete, and concise. AI codegen alone leaves you only requirements (incomplete) and code (bloated), however good the model.
Governance here is proactive: governing rules are the policy you read, enforced on every transaction. Elsewhere it is often reactive: procedures that catch problems after the fact.
Whatever comes in, governing rules come out — project after project. It reads your requirements in whatever form they already exist — plain English, Gherkin, actual regulation text — or you can request an interview to discover them.
And it fits what you already use: your methodology, standard tools, and shared artifacts, fostering collaboration between Business Users and Developers.
This is the start page for the GenAI-Logic Manager — where you manage projects, notes and resources. It's also your learning hub.
Say "hi" to your coding assistant — click to see important notes on models
Using a lighter or auto-selected model? Fine for exploring — for real logic you intend to keep, pick a frontier model (Claude Sonnet 5, Gemini 3 Pro, GPT-5, etc.) if your plan allows it, and review the AI's output either way, the same as you would any other engineer's.
Why this matters: AI-Enabled Projects.
You're already running in GitHub Codespaces — a cloud VS Code environment in your browser. Nothing to install. (Use Chrome or Edge — Safari has known compatibility issues with VS Code in the browser.)
The Ideal — executable business prompts, held to an enterprise standard
Widespread agreement on governance. It's a standing CIO concern — AI took the #1 spot in NASCIO's 2026 survey of state CIOs, and governance is the first concern NASCIO lists under it.
How do we get the speed and simplicity of AI — with the governance enterprises require?
Everyone who's had AI build a system hits the same wall afterward: what have I actually got? The developer can't be sure what it does when something changes. QA doesn't know what to test. The business can't say what policy it's really enforcing — and the auditor can't certify what nobody can read. Requirements are, and should be, incomplete. Code is complete but unreadable at scale.
The missing artifact is spreadsheet-like rules. Balance = sum of unshipped orders. Balance must not exceed credit limit. One line per requirement, readable by anyone who's ever read a spreadsheet. And like a spreadsheet, they react: change anything, every dependent value recalculates — automatically, on every path, nothing to forget. That's why they're trustworthy, not just readable.
That's governance by architecture, not process: logic everyone can read, and trust that the engine enforces.
Many assume AI will eventually get good enough that the prompt becomes the system of record, and code is just compiler output nobody reads. We hope so — but even then, governance still needs something you can read and check. Spreadsheet-like rules are that thing, regardless of which model wrote them.
Watch it live below: the save that fails in a moment is governance in action.
Paste these requirements into your AI assistant (allow several minutes):
Create basic_demo from samples/dbs/basic_demo.sqlite.
On Placing Orders, Check Credit:
1. The Customer's balance is less than the credit limit
2. The Customer's balance is the sum of the unshipped Order amount_total
3. The Order's amount_total is the sum of the Item amount
4. The Item amount is the quantity * unit_price
5. The Item unit_price is copied from the Product unit_price
Use case: App Integration
1. Publish the Order to Kafka topic 'order_shipping' when the date_shipped is not None.
The AI turns those requirements into five rules, one for each — click to see them in your IDE
The requirements are the docstring; the rules are the five lines of declare_logic(), one per requirement. The file is check_credit.py.
Note: the screenshot words requirement 2 as "…where date_shipped is null"; the prompt above says "…the unshipped Order amount_total". Both produce the same rule: your wording doesn't have to match ours.
Starting from a new database instead?
The prompt above starts from an existing database — the common real-world case, and much faster (no schema design step). You could have AI design a new database from scratch instead:
Say this to your AI assistant (allow several minutes):
Create basic_demo from samples/prompts/genai_demo.prompt
See it running: Press F5 using "API Logic Server Run (run project from manager)", and open the Admin App. Explore the API via Swagger, browse the data, and follow the relationships — all auto-generated from the data model.
What you're running is a service: an API, an Admin App, and the rules engine, over your database. Callers use the API (or messages, or MCP); the rules fire inside the service, at commit, from Python files in your project.
Now trigger it: open an unshipped Order for Alice, edit the Widget item:
Change the quantity to a very large number. Save.
Detail Instructions -- Screen Shots
Alter the quantity for an unshipped item:
- Show the Customer List
- Show the first Customer
- Show first Order
- Edit the Item
- Set the quantity
Key take-aways:
- The save fails — note the dialog. The dialog is governance in action.
- First thing to check: read the rules. The API and Admin App are mechanical; open
logic/logic_discovery/place_order/check_credit.pyin your project — that's where "is it right?" is decided. - That's 5 rules — not ~200 lines of code — governing this transaction across four tables. Not what you'd get if you'd asked AI alone. Let's explore.
AI Alone Writes Code That's Hard to Read or Trust — Here's What We Found
AI is genuinely good at UI, data mapping, boilerplate, etc — we see impressive results. Business logic is the exception.
Left unguided, any AI assistant — including the one that just built basic_demo for you — generates a running system from this requirement. On inspection, we found three problems:
Not readable — you can't govern what you can't read (5 vs ~200 lines)
~200 lines of procedural code — hard to read, intent unclear:

Same 5 requirements from the Check Credit prompt in "The Ideal" above — handed to AI with no guidance, it generated this: procedural/credit_service.py — ~200 lines. Open it and judge for yourself.
5 declarative rules — readable at a glance:

logic_discovery/place_order/check_credit.py — same 5 requirements, same AI.
~200 lines is a demo-scale number — a real system runs 1-2 orders of magnitude more requirements, and proportionally more procedural code to match. That's why business logic ends up as roughly half the total effort on a real system. Nobody can audit that at a glance — not the next developer, not compliance, not you in six months. At that scale, an auditor can't read it all — they can only sample, and hope.
Not trustworthy (a) — subtle reparenting bugs even from a good spec
The AI's code handled updates, but missed two re-parenting cases:
- Change an item's product, and the order wasn't re-priced — the item kept its old price, and the error propagated to the order total and the customer balance.
- Move an order to another customer, and the old customer's balance stayed stale.
Found only by specifically testing what happens when a row is reparented to a new owner: the A/B test. Root cause: path confusion — procedural code must enumerate every change path (insert, update, delete, reparent) by hand, and it's easy to miss one.
There's a structural problem underneath the bugs, too: AI pattern-matches dependencies, it doesn't compute them — so the odds of a miss go up as the system grows. More detail →
Not trustworthy (b) — whole paths silently missing from a typical spec
The example above presumed an excellent, declarative spec — but specs aren't always so good. We tried it with a typical one: check credit on placing an order, phrased the way a developer naturally writes it. We gave that requirement to two frontier models, with no GenAI-Logic, and told them explicitly not to use rules:
Note: this is a test of native AI coding ability — please do not use ApiLogicServer, GenAI-Logic, LogicBank, or any other code-generation or business-rules/rules-engine framework. Just plain hand-written code (standard web framework + ORM of your choice).
Using basic_demo.sqlite, build a system (api + web app) that lets us enter orders.
Here's what needs to happen when someone places an order:
- For each line item on the order, look up the product's price and multiply by the quantity to get the item's amount.
- Add up the item amounts to get the order's total.
- Add the order total to the customer's balance.
- Before we let the order go through, check that the customer's balance doesn't go over their credit limit — if it would, reject the order.
Both produced the same shape of code: one function, wired to order creation. No update path. No delete path — confirmed in the actual code.
Probed directly: change an item's quantity, delete an item, reassign an order to a different customer, reassign an item to a different product. Every case, both models, left stale data behind. No error. Nothing to catch it.
Key takeaways:
- The logic wasn't buggy so much as absent — it existed for exactly one path and nowhere else. Full experiment →
- A similar finding, looking beyond logic: the hand-written API has no PATCH or DELETE on any resource either — not a bug, just more of what the prompt never asked for. Full assessment →
Not maintainable — every regeneration re-exposes you to (a) and (b)
Hand-editing 200 generated lines isn't a real option — nobody reliably patches the output of a code generator, any more than you'd hand-patch a compiler's output. That leaves one path: change the prompt and regenerate.
Regen risks the same bug, every time. The AI re-derives everything from scratch, with no guarantee it reproduces the paths that already worked. Adding one small constraint — a one-line change — means regenerating and re-reviewing the whole system, every time, at every table. On a real system that's not a quick edit. It's hours, real AI cost, and a fresh chance at a new bug — to make a change that should have taken a minute.
That's not (only) a capability gap — it's what happens when dependencies are expressed as procedural code: real opportunities for subtle, hard-to-spot bugs. With rules, those same dependencies are handled deterministically by the rules engine — computed once, checked every time. That's the difference this document shows.
We're deeply impressed with AI — this is about closing the gap it has here: logic. That's next.
Rules You Can Read, Trust, and Maintain — Governance by Architecture
What you just built — run it, debug it, change it in your existing IDE
Run it. You've probably used AI to generate code before — so what's different here?
Difference 1: it produces executable models, not code. You just ran that project. Instead of a pile of procedural code, you got artifacts that declare structure or policy rather than procedure — same 5 requirements, same AI:
- Data model —
database/models.py - Full JSON:API — Swagger, pagination, optimistic locking (
api/expose_api_models.py— 52 lines, zero per-table code) - Admin App — multi-table, with navigations and lookups (
ui/admin/admin.yaml— simple YAML, not HTML/JS) - Business logic — logic_discovery/place_order/check_credit.py — 5 rules (~40X less), same requirements, same AI, 0 bugs
Difference 2: the logic itself is declarative. 5 lines, intent still clear — not ~200 lines of procedural frankencode. That's what declarative buys — more on that below.
It's plain Python — standard tooling applies. Security is opt-in, not default — bootstrap RBAC anytime with genai-logic add-auth.
The save you just saw fail was enforced by exactly one of those 5 rules.
Debug it. No new tools required. The rule chain that just fired is in the log — plain text, readable in your terminal or editor: sample trace. A live run writes the same thing to the standard log, logs/als.log.
Every rule is a plain Python function or lambda. Set a breakpoint on any calling= function or as_condition= lambda in your IDE, exactly like you would anywhere else in the codebase — no proprietary debugger, no special UI.
Change it. Ask your AI assistant for a new rule, in plain English:
Customers should not be able to create new orders if they have unresolved past due letters.
There was no Letter table in the model — the AI adds it, relates it to Customer, and declares a count + a constraint. One sentence creates a schema change and two new rules — automatically integrated with the 5 already there. No need to open check_credit.py to find where this belongs, or trace the other rules to check for conflicts.
To change a requirement later, edit its requirements.md and say "implement reqs". The AI diffs the new text against the existing rules and changes only what differs. The requirement, the rules, and the AI's assumptions are all files in your repo, so changes go through your normal review.
A lot just happened here — worth a closer look.
Trustworthy and Auditable — AI Driven Rules (AI, Context Engineering, Rules engine)
Two funnels, converging on one engine, at the same commit point:
AI translates intent, from virtually any format (NL, Gherkin, pseudocode, formulas), as shown in this diagram. This means you can use your existing approaches/methodologies, which drives a repeatable process.
Driven by Context Engineering — translates AI intent into declarative spreadsheet-like rules, not the procedural code (with all the code-sprawl issues above). The result stays as concise as the requirement itself: ~40x less than the equivalent code in this example (consistent with production data from the predecessor system — see the Appendix), since rules are deterministic, path-independent expressions of what, not how.
Rules — enforced at runtime by the rules engine. All transaction sources — APIs, messages, MCP, agents, workflows, and whatever comes next — converge here. Rules aren't called from your code; they're wired into a single SQLAlchemy before_flush listener, loaded once at server start. All transaction sources pass through that one listener at commit, where rules govern for every path. No bypass — there's no second door.
Not a RETE engine. Classic rules engines are called with a bag of objects, pattern-match across them, and re-derive everything — built for decision logic. This one is purpose-built for transactions: it hooks the ORM, receives the actual change events (Item inserted; Order.amount_total moved from X to Y), and fires only the rules those changes affect, maintaining aggregates incrementally instead of recomputing them. Why this matters →
↳ Declarative rules are trustworthy, since they're automatically invoked and ordered
The "Change it" example above — like maintenance generally — was remarkably simple, because rules are declarative:
- No need to call the new logic. Rules are invoked automatically - regardless of the originating path. You can trust that they'll always run.
- Order doesn't matter. Open
check_credit.pyand shuffle the five rules into any order you like. Rerun — still correct. Try that with 200 lines of procedural code. You can trust that they'll run in the right order. - You got more than you asked for. The original requirement said "On Placing Orders, Check Credit" — insert time. But the save that failed was an edit to an existing order. Nobody wrote an update-time check.
Functions don't behave like that. So why is that? Traditional logic is procedural — you own how: when it's called, and in what order. Declarative logic — rules — is about what, not how: you state the fact, and the system takes responsibility for invocation and ordering.
| Property | Why it matters |
|---|---|
| Auto-reused | Declared once, enforced over every change path — no per-path handlers to write or miss |
| Auto-invoked | Fires at every commit, from every caller — can't be forgotten, can't be bypassed |
| Auto-ordered | The engine computes dependency order — add a rule anywhere, it finds its place |
| Auto-chained | A change in one table fires dependent rules in another — so changes to Item's amount adjust the Order's total |
Rule.sum(derive=Customer.balance, as_sum_of=Order.amount_total, where=lambda row: row.date_shipped is None) looks like a function call — it isn't one. Grep this codebase for check_credit( — you won't find a call site. Nothing calls it. It runs because it's declared, not because something invokes it.
This is bigger than the ~40x less code. With procedural code, seeing a function isn't enough — you still have to trace every call site to know whether it actually runs for the path you care about. With a rule, seeing it is the proof: Auto-invoked guarantees it fires everywhere, so reading the rule tells you it runs — without the path analysis you'd otherwise have to do yourself.
Reading a rule tells you it runs, and that everything that depends on it is chained and re-derived — without tracing call sites or dependency chains. In code, that tracing is exactly where the bugs are. The reparenting bugs found earlier were this: reparenting silently left one side of the balance stale.
If it helps: think of a spreadsheet — B10 = SUM(B1:B9) isn't called, it reacts. Rules react the same way to changes in what they depend on.
Full writeup: declarative/procedural comparison.
↳ Rules are the governance you can read and trust — because intent is only an incomplete sketch
Natural language requirements are — and should be — a sketch, not complete. (Otherwise, it would be code!) That's exactly what you want to hand to a capable collaborator: not every detail spelled out, just enough for them to run with it and do what you meant, not merely what you said. AI provides real value there — no artificial syntax to learn, just the gaps filled the way a good team member would fill them.
But that same incompleteness is why natural language requirements can't be the system of record. An auditor needs something rigorous and complete to check against.
Rules are a suitable system of record — rigorous, complete — for auditing:
- Readable — ~40x less than the procedural equivalent in this example, critical at enterprise scale
- Trustworthy — the engine guarantees it: an auditor isn't tracing execution paths, complex dependency chains, or worrying code did not get called at all. This is the exact chain AI's procedural code missed earlier — reparenting an Item silently left one side of the balance stale.
This is what people mean by "governance by architecture, not discipline" — see the full idea, tying this together with everything else here, further down this page.
The missing governance layer — delivering AI's speed and simplicity, with the governance enterprises require
AI Driven Rules are a new piece of enterprise infrastructure: AI's speed and simplicity, with the governance enterprises require, brought into your existing architecture.
They sit alongside the infrastructure you already rely on — your database, Kafka, security — and make what AI creates enforceable on every transaction, from every source.
Think of a DBMS — the rules are the DDL, the rules engine is the database server. The rules are plain Python files in your project, under source control, the way DDL is a script you keep. The rules engine runs inside your service and enforces them at commit, the way a database server enforces its schema.
Project Governance — read the rules first, then manage the logic (alerts, diagrams, health check, tests)
↳ Read the rules first — readable (complete and concise) and trustworthy
When a system is generated, the first question is whether it's right, or close. Business logic is the focus; the API and Admin App are mechanical.
Rules are readable: complete, and concise (~40x more concise than the code, in this example). And you can trust what you read: the rules are deterministic, and the engine calls them, orders them and handles their dependencies, so there is nothing to trace. The alternatives don't give you that:
- Requirements are easy to read, but incomplete — and a little vague. They leave decisions unmade and open to interpretation, so they can't tell you what the system does.
- Code is bloated, and hard to trust. There's far more of it, and you have to trace where it's called, whether it's ordered correctly, and whether dependencies are handled.
logic_discovery/place_order/check_credit.py: five requirements, five rules. What they can't show you is what the requirement left unsaid and the AI had to assume. That's next.
↳ AI Alerts — proactive human-in-the-loop, every AI assumption
Every requirement leaves things unsaid — the AI can and should resolve that ambiguity. But that carries the responsibility to provide a proactive heads-up so you can confirm the decision; that's shown in the report above.
For anything with no safe default, it stops outright — trained by Context Engineering to do exactly that, rather than guess and move on. No code written for that piece, a FIXME left in its place, and the real options listed here for you to decide. That's the comforting part: not just "the AI made a call, here it is," but "the AI knew this one wasn't its call to make."
You review the judgment calls, not the code. Full report.
↳ Logic Flow Diagram — visualize logic flow
A compliance reviewer can check the implementation in minutes, not by reading code. Full report — the same report generates for any project, including the enterprise-scale ones below.
↳ Health Check — logic analysis / usage / utilization
Ongoing hygiene, not just at creation: run any time to confirm the codebase still holds up as the project evolves — rule adoption, dependency-tracking integrity, missing docstrings, across the whole project. Full report.
↳ Test Creation — requirements traceability (from rules analysis)
The three reports above analyze the rules as declared — this one proves they ran. Behave tests trace straight back to the requirement that drove them — and the report shows which declarative rules fired for each scenario, with before/after values, not just pass/fail. Requirement → test → rule → execution log, in one place. Full report.
Governance at Scale — the architecture reliably produces rules, project after project
Governance depends on rules — they're what you can read, trust, and audit. But the manual rules-vs-code discipline is hard to sustain across projects: someone has to walk the floor, bird-dogging and catching the reversions, and when the bird-dog goes away, the procedural code sneaks back in.
Here, the architecture produces the rules. Whatever the requirement format, Context Engineering directs the AI to generate rules, not procedural code. No team has to remember to choose rules, or be policed into it. Rules are what comes out.
The evidence: a head-to-head test gave the same naturally procedural spec — the kind most likely to produce procedural code — to native AI and to this pipeline. Native AI built the insert path and silently dropped update and delete. The pipeline produced 5 governed rules covering every path. Same input, same AI — the difference was the architecture.
And it repeats: we've run these three samples hundreds of times, and the output has always been rules. The Context Engineering is tuned not just on rule syntax but on the best patterns of rule use, and because the output is rules, anyone can read and check them.
The GenAI-Logic side of that test, in full: samples/basic_demo_genai_logic — the procedurally-phrased prompt, the 5 rules it produced, and confirmation all 9 change paths are governed, not just the one the prompt described.
The native-AI side, in full: samples/bd_claude_native_ai — the actual code, the prompt, and the unedited transcript.
Full case: Governance at Scale.
Enterprise-Class Results — enabled by a pre-built enterprise architecture (click to see real projects)
Enterprise Architecture — EAI, MCP, Logic Using AI, RBAC, Custom UIs
You've seen the API work, and you now know how the logic behind it holds up — declarative,
auto-enforced, governable. Fair question: how does it integrate with your other enterprise
infrastructure — Kafka messages, B2B partners, AI agents, role-based access, custom UIs? The
same Context Engineering that knows how to generate rules (not code) also knows key enterprise
patterns. More on system vs. domain knowledge →
↳ Enterprise Integration (EAI) — B2B partner orders via Custom API or Kafka
The demo above showed Publish the Order to Kafka topic. For the subscribe side, see samples/basic_demo_eai/readme.md: B2B orders from partner systems, via a Custom API or Kafka subscriber, including lookups so partners send "Account": "Alice" (not internal IDs). One project handles both directions — no separate system to stand up:
Below is the portion of the requirement for subscribing:
Feature: Kafka Subscribe Order Integration - Inbound orders from sales channel
Scenario: Accept inbound orders from sales channel
Given an inbound order message in JSON format (message_formats/order_b2b.json)
When the message is received from Kafka topic order_b2b
Then map Account to Customer by name
And map Items.Name to Product by name
And map Items.QuantityOrdered to Item.quantity
Notice that you can define complex message/API formats by example — drop a sample JSON file next to the requirement and reference it, instead of writing out a schema. For more, see samples/requirements/Order-EAI/message_formats.
Also notice what that requirement does not say. Enterprise-grade reliability —
a 2-message save that never loses data mid-parse, a queryable error_text reason
on every failure instead of a buried log line, and the same Check Credit rule
enforced no matter which path wrote the row — comes with every Kafka subscriber
this platform generates. You don't ask for it.
↳ MCP (Model Context Protocol) — your API is agent-discoverable out of the box
Your API is MCP-discoverable out of the box (/.well-known/mcp.json). Copilot, Claude, or ChatGPT can find the schema and answer natural-language queries against it. There's no discovery layer for you to write — see samples/basic_demo_ai_rules-supplier/readme_ai_mcp.md
Here, an end user makes a NL request to find some data, and send email — the same governing rules enforce it, whether the request came from MCP, the API, or a form. No new door, no new bypass.
You can also use MCP in your IDE to issue queries in natural language.
↳ Vibe Custom UIs — keep your vibe tool, point it at a governed backend
The API and business logic are already built and governed — that's the part that's hard to get right, and now you don't hand-write it. What's left is the UI, and that's exactly what vibe tools (Cursor, v0, etc.) are great at.
Point yours at the generated API, and it renders against real, governed data — the same logic runs no matter what's calling it. One database, one API, any number of custom front ends: dashboards, tree views, maps, card layouts — all shown below, same backend, all generated in about 15 minutes with no hand-written JavaScript.
The card layout above, worked first try:
Add an option on the Employee List page to show results as cards, and
show the employee image in the card.
More prompts (tree view, map, landing page) and what each produced: Admin-Vibe-Sample.
Quick-start a React app from your (possibly customized) admin app:
Create a new react app named my-app-name from ui/admin/admin.yaml
↳ RBAC (Role Based Access Control) — row-level security, declared not coded
Declare row level security using technologies like Keycloak — and declare it the same
way you declare logic: describe it, AI writes declare_security.py. Same project as
above:
sales role reads Customer and Order, but can't insert, update, or delete
sales sees only customers with credit_limit >= 3000, or a positive balance
turns into:
DefaultRolePermission(to_role=Roles.sales, can_read=True, can_insert=False, can_update=False, can_delete=False)
Grant(on_entity=models.Customer, to_role=Roles.sales,
filter=lambda: models.Customer.credit_limit >= 3000, filter_debug="credit_limit >= 3000")
Grant(on_entity=models.Customer, to_role=Roles.sales,
filter=lambda: models.Customer.balance > 0, filter_debug="balance > 0")
# two Grants for the same role are OR'd — either condition qualifiesNo SQL, no per-endpoint checks to remember — the filter applies automatically everywhere that role touches Customer: the API, the Admin App, MCP queries. See samples/basic_demo_eai/security/readme_security.md for more NL → declaration examples.
↳ Logic Using AI — governed reasoning inside deterministic rules
Rules that call AI for genuinely judgment-call decisions (e.g. picking a supplier under disrupted shipping lanes). Such AI "proposals" are governed by the deterministic rules to ensure results conform to business policy, with a full audit trail of every AI request and response — see samples/basic_demo_ai_rules-supplier/readme.md
The rule below is one line (__Use AI__ to Set...) inside an otherwise ordinary logic declaration — deterministic and AI rules aren't two systems, they're the same DSL:
On Placing Orders, Check Credit:
1. The Customer's balance is less than the credit limit
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
3. The Order's amount_total is the sum of the Item amount
4. The Item amount is the quantity * unit_price
5. The Product count suppliers is the sum of the Product Suppliers
6. __Use AI__ to Set Item field unit_price by finding the optimal Product Supplier based on cost, lead time, and world conditions
Three real systems — built from prompts, governed by rules
Put that enterprise awareness to work, and here's what it builds.
Prompt-to-app tools build the screens. Here are three complete systems — the API, the Admin App, and the harder part, business logic governed by rules — created using each team's existing requirement methodology.
Fast, and better: the results below replaced work reported in person-years, and delivered where the hand-built versions fell short: a working allocation, and audit failures caught.
Click to see the prompt and the rules it produced:
↳ Budget allocation — complex cascading cost allocation, two levels deep
Cascading cost allocation illustrates complex business logic. Built by hand, it was reportedly four developers over two years, and it didn't deliver. Now it's created from this prompt (↗) — the API, the Admin App, and the logic:
Departments own a series of General Ledger Accounts.
Departments also own Department Charge Definitions — each defines what percent
of an allocated cost flows to each of the Department's GL Accounts.
An active Department Charge Definition must cover exactly 100% (derived:
total_percent = sum of lines; is_active = 1 when total_percent == 100).
Project Funding Definitions define which Departments fund a designated percent
of a Project's costs, and which Department Charge Definition each Department
applies. An active Project Funding Definition must cover exactly 100% (derived:
total_percent = sum of lines; is_active = 1 when total_percent == 100).
Projects are assigned to a Project Funding Definition.
When a Charge is received against a Project, cascade-allocate it in two levels:
Level 1 — allocate the Charge amount to each Department per their
Project Funding Line percent → creates ChargeDeptAllocation rows
Level 2 — allocate each ChargeDeptAllocation amount to that Department's
GL Accounts per their Charge Definition line percents
→ creates ChargeGlAllocation rows
Constraint: a Charge may only be posted if the Project's
Project Funding Definition is active.
And the rules it produced:
Trust: read the resultant rules (↗) — they'll monitor every transaction.
Verify: AI read those same rules and wrote a Behave test suite (↗) from them — no test written by hand. Running it produces an automated Logic Report (↗) — 7 scenarios, 37 steps, all passing, with the rule chain's execution trace on every scenario. Not a hand-written report — regenerate it any time the rules change, and it's still true.
↳ Canadian CBSA duty calculation — rules distilled straight from the regulation text
This prompt (↗) illustrates reading regulations directly from the web — business language, not rules. One practitioner who tried it estimated it replaced a project of about a person-year:
Create a fully functional application and database
for CBSA Steel Derivative Goods Surtax Order PC Number: 2025-0917
on 2025-12-11 and annexed Steel Derivative Goods Surtax Order
under subsection 53(2) and paragraph 79(a) of the
Customs Tariff program code 25267A to calculate duties and taxes
including provincial sales tax or HST where applicable when
hs codes, country of origin, customs value, and province code and ship date >= '2025-12-26'
and create runnable ui with examples from Germany (CETA — exempt), US (CUSMA — exempt), Japan (CPTPP — exempt), and China (subject, 25%)
Transactions are received as a CustomsEntry with multiple
SurtaxLineItems, one per imported product HS code.
That prompt creates:
- An MCP-enabled API and an Admin App. Those are mechanical and typically don't need review.
- The business rules which express your business logic and govern all updates. This is the key part: review them to verify the AI understood and translated your intent. Here are the rules it produced (nearly as concise as the requirement, but complete and deterministic):
You can use the Rules Diagram to visualize rule chaining:
Read the rules (↗) yourself.
Proactive Human-in-the-loop: the ad-libs report (↗) lists every low-confidence decision — so you know exactly where it guessed.
↳ Low Value Import Shipments (CLVS) — screens dangerous goods, using internationally agreed rules
The business description (↗) and actual requirements (↗) illustrate Gherkin requirements, with audit-grade rules:
This system subscribes to a broker feed of messages in complex XML formats; the transformation into business objects is by example, from sample XML (↗).
Rules make it auditable — logistics firm participation is subject to audit. Failure would mean hiring 100+ additional staff, an 8-figure exposure. Auditors can read the rules ↗, and trust they will be enforced - not sample and hope. (Full writeup →)
Business Users and Developers, Collaborating — one governed artifact, a Friendly IDE, just enough guidance
A Business-User-Friendly IDE — same AI, same governed output, no developer tooling to learn
No Proprietary Interface, No Rigid Structure — just ask the AI when you need guidance
Traditional studios lock you into proprietary, rigid interfaces. Here, AI isn't boxed into a fixed structure — and when you need guidance, just ask.
You keep your own methodology, and you never face a blank page: ask for just enough guidance, when you need it.
One Artifact, One Toolset — promotes Business User and Developer collaboration
No proprietary interface means no proprietary artifact, either. The rule a business user reads and the rule a developer debugs are the same lines, in the same file, in the same IDE — standard Python, standard tooling, your infrastructure, not a proprietary one.
Standard means no rewrite when the limit is reached — a proprietary IDE and language hit a wall the BU version can't get past; a developer has to rebuild it in real code to meet corporate standards. Here the developer opens the same file. No paying twice for the same logic.
The result: BU/IT collaboration instead of finger-pointing over whose fault the gap was — one artifact, one team owns it, from day one.
And When You Need Even More Guidance — just ask the system to define Requirements From Interview
And when you need even more guidance, just ask the system to define the requirements from an interview — AI will interview you on what's still ambiguous, then confirm before building. No spec-writing skill required going in.
Governance by Architecture — rules for design, runtime, review and maintenance
Discipline means someone has to remember: write the rule correctly, for every path, and keep doing it as the system grows and deadlines press. The burden lives in people — and it slips.
Architecture means the rules are created automatically from your requirements, and automatically govern every transaction — nothing to remember.
Not governance by process: the system itself produces rules you can read and check. At every point it matters:
At design time — anything in, rules out
Prompt, Gherkin, regulation text, spreadsheet formula: whatever form intent arrives in, Context Engineering steers it toward rules, not code. That's what the pipeline does by construction, not a best practice to follow.
At runtime — enforced, not called
Every transaction, every caller (API, message, MCP, agent, workflow) fires through the one commit point nothing can route around. Nothing to forget, because there's nothing to remember.
At review time — executable business documentation
The same rules are code to a developer, business documentation to a business user confirming policy, and audit evidence to the auditor certifying it. And you can trust it runs: reading a rule needs no call-site tracing.
Review is becoming where AI-built systems stall: with code there is far more to read, and reading it doesn't tell you what runs. Here there is ~40x less (in this example), and what you read is what is enforced.
At maintenance — change one rule, not every path
With code, every change is another chance to miss a path; here it's one declaration, and the engine handles the rest. Add a rule anywhere and the engine finds its place. No call sites to hunt down, no execution order to keep straight — nothing to remember when the system changes, which is where much of its cost lives.
That works across the organization and the life cycle because rules are the one artifact that is complete, readable and executable:
Same claim, every time someone needs it — design, runtime, review, or maintenance: what happens doesn't depend on anyone's diligence. It depends on the architecture.
Full case: Governance by Architecture, Not Discipline.
Go deeper — beyond credit-check: security, customization, integration, logic debugging
Guided tour — the full 30-45 min build, past what "The Ideal" showed
Create basic_demo (auto-opens with guided tour option):
genai-logic create --project_name=basic_demo --db_url=sqlite:///samples/dbs/basic_demo.sqliteInside the project: Say to your AI assistant: "Guide me through basic_demo" (30-45 min hands-on tour).
Teaches API creation, declarative rules, security, and Python customization. Fail-safe — scripts ensure no coding errors.
Your AI as on-call consultant — ask it anything, verify it doesn't just recite
Same materials, same AI you've been using — it doesn't just write rules, it automates everything above and helps when things break: EAI's 2-message Kafka pattern, the AI/Request Pattern wiring, Executable Requirements' pre-coding schema assessment — all documented training material (docs/training/*) the AI reads before writing your code, not generic knowledge it's guessing from. Ask "what are rules?" or "how do rules work?" — or, without an AI handy, just read samples/basic_demo_logic_gov/logic/readme_logic.md — same material.
Ask it your own questions directly:
- Is this really infrastructure, like a database?
- Is this a black box? How do I debug a rule chain?
- Can I verify this with tests, not just take it on faith?
- What did the AI decide on its own that I should double-check? (the ad-libs report)
- Can I see a governance/health report for this project's logic?
- What does it take to migrate off this if we ever wanted to?
- How does this perform at scale?
- What does this integrate with — APIs, workflows, agents, MCP?
- Does this work with my existing database?
More background: Eval Guide.
Put together: once the AI knows how the system works, it doesn't just generate rules instead of code — it helps you debug them, and helps you understand them. A design assistant, not just a coding assistant.
The AI was trained on this material — can you trust its answers?
Don't take them on faith. Ask the same question a different way, or ask something not covered here — like where this architecture breaks down. If it just recites the same lines back, you've caught it. If it reasons, that's the test passing.
Ready to see it for yourself? The demo catalog below runs the same systems live.
The section above showed you pre-built samples to browse. These are the same use cases, but as commands you run yourself — paste one into your AI assistant and it builds that project for you, live.
Tip: every project is AI-enabled — once it's built, ask your AI assistant how it works
Each of these builds a complete system from a single prompt or command — 💬 = say it to your AI assistant, › = run in a terminal:
| Use Case | 💬 Say to your AI, or › run | What You'll Learn |
|---|---|---|
| Allocation with AI Rules demo_allo_dept_gl |
💬 create demo_allo_dept_gl from samples/prompts/allocation.prompt.md or › genai-logic create --project_name=demo_allo_dept_gl --db_url=sqlite:///samples/dbs/starter.sqlite |
- Cascade Allocation (Costs to Depts/GL) - AI Rules for fuzzy match to project |
| Customs CLVS demo_customs_clvs |
› genai-logic create --project_name=demo_customs_clvs --db_url=sqlite:///samples/dbs/customs.sqlite | - Governed Business Systems - EAI (using XML), textual requirements |
| Customs Surtax demo_customs_surtax |
💬 create project demo_customs_surtax from samples/prompts/customs_cbsa.prompt.md | - New Business System from Regulations |
Running a cloned project? F5 won't work until the venv is set up — see Project-Env for options (
genai-logic run, symlink, or local venv).
Each of these builds a complete system from a single prompt or command — 💬 = say it to your AI assistant, › = run in a terminal:
| Use Case | 💬 Say to your AI, or › run | What You'll Learn |
|---|---|---|
| Use Case 1: AI Rules demo_ai_rules_supplier |
› genai-logic create --project_name=demo_ai_rules_supplier --db_url=sqlite:///samples/dbs/basic_demo.sqlite | - Use AI Rules (req pattern) to choose Optimal Supplier, per world conditions |
| Use Case 2: Governed MCP Server demo_mcp_send_email |
💬 implement reqs samples/prompts/demo_mcp_send_emailOr › genai-logic create --project_name=demo_mcp_send_email --db_url=sqlite:///samples/dbs/basic_demo.sqlite |
Executable Requirements (fast path) or manual steps - Bus Users compose new service to send email to overdue customers, subject to email opt-out rules - Create custom API with NL - Create an email service (req pattern) |
| EAI: Enterprise App Integration demo_eai |
› genai-logic create --project_name=demo_eai --db_url=sqlite:///samples/dbs/basic_demo.sqlite | - Executable Requirements - Create custom API with NL - Create Kafka Listener with NL |
| Use Case 4: Vibe Dev Backend demo_vibe |
› genai-logic create --project_name=demo_vibe --db_url=sqlite:///samples/dbs/basic_demo.sqlite | - UI elements, eg, Cards, Maps, Trees... |
| Requirements From Interview basic_demo_rfi |
💬 paste samples/prompts/basic_demo_rfi.prompt | - Most of this prompt is fully specified (AI builds those parts directly, no questions asked) - And requests interview ("Also, interview me to work out this general intent: ...")... AI interviews you on that part only, confirms before building - Real transcript included |
| Use Case 5: Business Users webgenai |
See webgenai/ in this Manager |
- Create systems from browser, with logic, sample data and derived attributes |
Advanced examples and specialized patterns:
| Demo | 💬 Say to your AI, or › run | What You'll Learn |
|---|---|---|
| Executable Requirements | See samples/requirements/readme_reqmts.md | Create from Gherkin requirements implement reqs |
| New system from prompt | › genai-logic genai --using=samples/prompts/genai_demo.prompt | Create systems from prompt Like WebGenAI, but from IDE |
| Coding Samples | › code samples/nw_sample | Useful code examples Search: #als |
| MCP Discovery demo_copilot_mcp_discovery |
› genai-logic create --project_name=demo_copilot_mcp_discovery --db_url=sqlite:///samples/dbs/basic_demo.sqlite | test rules via Copilot access to MCP Server |
Copy Snippets for venv:
source venv/bin/activate # windows: venv\Scripts\activate
source ../venv/bin/activate # windows: ../venv\Scripts\activate
python -m venv venv # may require python3 -m venv venv
Detail Procedures
Specific procedures for running the demo are here, so they do not interrupt the conceptual discussion above.
You can use either VSCode or Pycharm.
1. Establish your Virtual Environment
Python employs a virtual environment for project-specific dependencies.
If the project was created in this Manager (or opened from it), the venv is already configured — just press F5.
If the project was cloned from git, choose one of:
-
Quickest (no VS Code setup): from the Manager terminal (or, use Code Assistant):
genai-logic run --project-name=<project-name>
-
Mac/Linux with F5: create a symlink to the Manager venv:
cd <project> sh venv_setup/venv.sh symlink # reload VS Code window, then F5
-
Any platform: create a local venv:
sh venv_setup/venv.sh go # mac/linux .\venv_setup\venv.ps1 go # windows
For PyCharm, you will get a dialog requesting to create the venv; say yes.
See Project-Env for more information.
2. Start and Stop the Server
Both IDEs provide Run Configurations to start programs. These are pre-built by genai-logic create.
For VSCode, start the Server with F5, Stop with Shift-F5 or the red stop button.
For PyCharm, start the server with CTL-D, Stop with red stop button.
3. Entering a new Order
To enter a new Order:
-
Click
Customer 1 -
Click
+ ADD NEW ORDER -
Set
Notesto "hurry", and pressSAVE AND SHOW -
Click
+ ADD NEW ITEM -
Enter Quantity 1, lookup "Product 1", and click
SAVE AND ADD ANOTHER -
Enter Quantity 2000, lookup "Product 2", and click
SAVE -
Observe the constraint error, triggered by rollups from the
Itemto theOrderandCustomer -
Correct the quantity to 2, and click
Save
4. Update the Order
To explore our new logic for green products:
-
Access the previous order, and
ADD NEW ITEM -
Enter quantity 11, lookup product
Green, and clickSave.
Explore Pre-created Samples
The samples folder has pre-created important projects you will want to review at some point (Important: look for readme files):
-
nw_sample_nocust - northwind (customers, orders...) database
- This reflects the results you can expect with your own databases
-
nw_sample - same database, but with with customizations added. It's a great resource for exploring how to customize your projects.
- Hint: use your IDE to search for
#als
- Hint: use your IDE to search for
-
tutorial - short (~30 min) walk-through of using API Logic Server using the northwind (customers, orders...) database
You can always re-create the samples
Re-create them as follows:
- Open a terminal window (Terminal > New Terminal), and paste the following CLI command:
ApiLogicServer create --project-name=samples/tutorial --db-url=
ApiLogicServer create --project-name=samples/nw_sample --db-url=nw+
ApiLogicServer create --project-name=samples/nw_sample_nocust --db-url=nw
Hiding Front Matter
To hide the YAML or JSON front matter (the metadata block at the top of your markdown files) in the built-in VS Code markdown preview, you can adjust your editor settings:
- Open the Settings panel using Ctrl + , (Windows/Linux) or Cmd + , (macOS).
- Search for the following term:
markdown.previewFrontMatter. - Change the dropdown value from show to
hide.
The preview will now automatically strip the front matter from the rendered view.
Appendix
The A/B test's two bugs came from AI writing procedural logic and missing the reparenting case — old parent left stale when a foreign key is reassigned. Separately, AI was also asked to generate the Behave test suite for basic_demo_logic_gov directly from the declared rules — a credible, well-structured result, reactive and API-driven, comparable in shape to test infrastructure that took weeks to write by hand for other sample projects in this repo. But it has the same gap: no scenario reassigns an existing order's customer or an existing item's product. Same AI, same underlying reasoning pattern, two different generative tasks (write the logic, write the tests for the logic) — one recurring miss.
That's not a knock on either result — both are genuinely useful starting points. It's evidence for the underlying claim: AI reasons locally, case by case, not by systematically enumerating a dependency graph — and that blind spot doesn't go away because you ask it to "be careful about dependencies" in a different task. It shows up again. This is exactly what LogicBank takes off the table — not just the reparenting case, but the entire category: every change path (insert, update, delete, and their combinations with every foreign key and conditional aggregate), across every use case, from every source (API, message, MCP, agent). Not because the rules are written more carefully, but because the engine derives the paths structurally — there's no enumeration step left for anyone, human or AI, to get wrong.
The 40X figure isn't a one-off — it's consistent with two decades of production measurement on a predecessor system (Versata, 1995-2010: 94-99% of logic automated by rules, typically ~97%, across several dozen systems). The remaining 3-6% is exactly the hand-written event code the guard below governs — most of a real system falls inside the declarative vocabulary, not outside it. This is the architect's own measurement, not an independently audited figure — treat it as a strong internal data point, not third-party verification. Full history →
Purpose-built for transaction processing, not inference/decision logic. Why this matters →
Hand-written event code can reopen the bug class — if a row_event/commit_row_event mutates a row directly, that value skips derivation, cascades, and constraints entirely. But this isn't a silent hole: the engine refuses to start if it detects a mutating event without an explicit allow_row_mutation=True override. The safe alternative (early_row_event, or logic_row.insert()) gets full rule processing automatically. Net effect: the escape hatch is closed by default, and every place it's deliberately opened is a single grep away. Details →














