ApiLogicServer 16.1.3__py3-none-any.whl → 16.1.18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- api_logic_server_cli/api_logic_server.py +2 -1
- api_logic_server_cli/genai/genai_svcs.py +2 -2
- api_logic_server_cli/prototypes/base/.github/.copilot-instructions.md +558 -52
- api_logic_server_cli/prototypes/base/.github/.copilot-instructions.md.backup +1257 -0
- api_logic_server_cli/prototypes/base/.github/welcome.md +23 -9
- api_logic_server_cli/prototypes/base/docs/training/{logic_bank_api.prompt → logic_bank_api.md} +125 -4
- api_logic_server_cli/prototypes/base/logic/logic_discovery/readme_logic_discovery.md +15 -0
- api_logic_server_cli/prototypes/base/logic/readme_logic.md +1 -1
- api_logic_server_cli/prototypes/manager/.github/welcome.md +14 -10
- api_logic_server_cli/prototypes/manager/readme_vibe.md +376 -0
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/.github/.copilot-instructions.md +395 -47
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/.github/welcome.md +40 -0
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/customizations/logic/declare_logic.py +1 -1
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/docs/system-creation-vibe.md +1 -1
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/iteration/logic/declare_logic.py +1 -1
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/logic/logic_discovery/{check_credit.py → place_order/check_credit.py} +2 -2
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/readme_ai_mcp.md +2 -2
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/readme_vibe.md +1 -1
- api_logic_server_cli/prototypes/manager/samples/prompts/genai_demo.prompt +1 -1
- api_logic_server_cli/prototypes/manager/system/ApiLogicServer-Internal-Dev/copilot-dev-context.md +27 -0
- api_logic_server_cli/prototypes/manager/system/ApiLogicServer-Internal-Dev/propagate_copilot_changes.py +102 -0
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_formal.prompt +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/postgres/genai_demo_pg.prompt +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/reference/declare_logic.py +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/reference/genai_demo_logic.txt +1 -1
- api_logic_server_cli/prototypes/nw/Tutorial.md +1 -1
- api_logic_server_cli/prototypes/nw/integration/Sample-Integration.md +65 -48
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/METADATA +1 -1
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/RECORD +36 -32
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/WHEEL +1 -1
- /api_logic_server_cli/prototypes/base/docs/training/{logic_bank_patterns.prompt → logic_bank_patterns.md} +0 -0
- /api_logic_server_cli/prototypes/base/docs/training/{probabilistic_logic.prompt → probabilistic_logic.md} +0 -0
- /api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/logic/logic_discovery/{app_integration.py → place_order/app_integration.py} +0 -0
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/entry_points.txt +0 -0
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/licenses/LICENSE +0 -0
- {apilogicserver-16.1.3.dist-info → apilogicserver-16.1.18.dist-info}/top_level.txt +0 -0
|
@@ -1,3 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
version: 3.2
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## What is this?
|
|
8
|
+
This is Context Engineering for GenAI-Logic Projects (created into each project).
|
|
9
|
+
|
|
10
|
+
It is AI-generated technical documentation for AI assistants, created_by: AI (Claude 4.5) through code inspection, system operation analysis, and Socratic training with Val Huber.
|
|
11
|
+
|
|
12
|
+
It is used as bootstrap context for both developers (in IDE), and evaluators (AI-driven evaluation).
|
|
13
|
+
|
|
14
|
+
<br>
|
|
15
|
+
|
|
16
|
+
## 🏗️ What You Get (Auto-Generated Infrastructure)
|
|
17
|
+
|
|
18
|
+
The created project came from: `genai-logic create --project_name=... --db_url=...`
|
|
19
|
+
|
|
20
|
+
**It's a complete, production-ready microservice:**
|
|
21
|
+
|
|
22
|
+
✅ **Enterprise JSON:API** - Standard REST with filtering, sorting, pagination, and relationships
|
|
23
|
+
✅ **Production Admin UI** - Full CRUD interface at `/admin-app` with multi-table forms
|
|
24
|
+
✅ **SQLAlchemy Models** - Auto-generated from database schema in `database/models.py`
|
|
25
|
+
✅ **API Endpoints** - Auto-discovered REST endpoints for all tables in `api/customize_api.py`
|
|
26
|
+
✅ **Containerized** - Docker/Kubernetes ready with `devops/docker/` configuration
|
|
27
|
+
✅ **AI-Enabled (MCP)** - Discoverable metadata at `/.well-known/mcp.json` for Copilot/ChatGPT
|
|
28
|
+
|
|
29
|
+
**Created in ~5 seconds** - Working API server + Admin UI + Models from the database.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🎨 What You Do (Customization & Extension)
|
|
34
|
+
|
|
35
|
+
Now extend this generated foundation:
|
|
36
|
+
|
|
37
|
+
**Business Logic** - Add declarative rules (5 lines, not 200+ procedural code)
|
|
38
|
+
**Custom APIs** - Add endpoints in `api/api_discovery/` for complex business transactions
|
|
39
|
+
**Security** - Add RBAC with `genai-logic add-auth`
|
|
40
|
+
**React Apps** - Create custom UIs with `genai-logic genai-add-app --vibe`
|
|
41
|
+
**Integration** - Add Kafka events, webhooks, B2B APIs
|
|
42
|
+
**Testing** - Create Behave tests with requirements traceability
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Quick Start: See It Work
|
|
47
|
+
|
|
48
|
+
**Prompt 1: Create Project**
|
|
49
|
+
```bash
|
|
50
|
+
genai-logic create --project_name=basic_demo --db_url=sqlite:///samples/dbs/basic_demo.sqlite
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Result:** Complete project you open in your IDE (VS Code, PyCharm, etc.) with:
|
|
54
|
+
|
|
55
|
+
- Working JSON:API server with filtering, pagination, sorting
|
|
56
|
+
- Admin UI for data management
|
|
57
|
+
- SQLAlchemy models auto-generated from your database
|
|
58
|
+
- Container-ready for deployment
|
|
59
|
+
- Ready to run in ~5 seconds - vibe custom apps, etc...
|
|
60
|
+
|
|
61
|
+
**Prompt 2: Add Business Logic**
|
|
62
|
+
```text
|
|
63
|
+
On Placing Orders, Check Credit:
|
|
64
|
+
1. The Customer's balance is less than the credit limit
|
|
65
|
+
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
|
|
66
|
+
3. The Order's amount_total is the sum of the Item amount
|
|
67
|
+
4. The Item amount is the quantity * unit_price
|
|
68
|
+
5. The Product count suppliers is the sum of the Product Suppliers
|
|
69
|
+
6. Use AI to Set Item field unit_price by finding the optimal Product Supplier
|
|
70
|
+
based on cost, lead time, and world conditions
|
|
71
|
+
|
|
72
|
+
Use case: App Integration
|
|
73
|
+
1. Send the Order to Kafka topic 'order_shipping' if the date_shipped is not None.
|
|
74
|
+
```
|
|
75
|
+
**Result:** Creates equivalent of 200+ lines of procedural code (want to know more about that?)
|
|
76
|
+
|
|
77
|
+
Next: Ask me anything - common questions, how it works, what to try next...
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# About This File
|
|
83
|
+
|
|
84
|
+
**You are reading the bootstrap for context engineering materials.**
|
|
85
|
+
|
|
86
|
+
This file is the **entry point** for understanding GenAI-Logic architecture. Additional training materials are available:
|
|
87
|
+
|
|
88
|
+
**For Developers (in IDE):**
|
|
89
|
+
- This file: 1,587 lines of core architecture and patterns
|
|
90
|
+
- Plus `docs/training/` folder: LogicBank API reference, testing guide (555 lines), architecture deep-dives
|
|
91
|
+
- Total: **2,599 lines of context engineering**
|
|
92
|
+
|
|
93
|
+
**For Evaluators (web):**
|
|
94
|
+
- This file accessed via: https://apilogicserver.github.io/Docs/Eval-copilot-instructions/
|
|
95
|
+
- Additional materials referenced throughout and publicly accessible
|
|
96
|
+
|
|
97
|
+
**Two use cases:**
|
|
98
|
+
1. **Developers in IDE** - GitHub Copilot reads this to assist with logic creation, testing, security, custom APIs
|
|
99
|
+
2. **Evaluators** - AI assistants (Claude/ChatGPT/Gemini) read this for independent technical analysis
|
|
100
|
+
|
|
101
|
+
**How it was created:** AI-generated through:
|
|
102
|
+
- Code inspection and architecture analysis
|
|
103
|
+
- Observing system operation (rules traces, engine behavior)
|
|
104
|
+
- Socratic dialogue with Val Huber (40+ years designing business rules technology)
|
|
105
|
+
- Active validation (AI questioned claims, verified against observable behavior)
|
|
106
|
+
|
|
107
|
+
**Why this matters:** These materials demonstrate senior-level technical understanding that survived AI scrutiny. When multiple AIs analyze them, they reach similar conclusions because they're analyzing genuine architectural patterns, not marketing claims.
|
|
108
|
+
|
|
109
|
+
**See:** [Eval.md](https://apilogicserver.github.io/Docs/Eval/) explains the AI-driven evaluation methodology this enables.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
1
113
|
<!--
|
|
2
114
|
═══════════════════════════════════════════════════════════════════════════════
|
|
3
115
|
🚨 MANDATORY: READ THIS FIRST - NO EXCEPTIONS 🚨
|
|
@@ -123,6 +235,20 @@ User: "load .github/.copilot-instructions.md"
|
|
|
123
235
|
|
|
124
236
|
---
|
|
125
237
|
|
|
238
|
+
## 📖 Content Organization Protocol
|
|
239
|
+
|
|
240
|
+
**WHEN USER ASKS: "how do rules work" or "explain the rules engine"**
|
|
241
|
+
**PRIMARY ANSWER**: Provide the **"How the Rules Engine Works"** 3-phase overview below:
|
|
242
|
+
1. Authoring (AI-assisted, human-reviewed)
|
|
243
|
+
2. Engine Initialization (Deterministic analysis)
|
|
244
|
+
3. Runtime Enforcement (Commit-time)
|
|
245
|
+
|
|
246
|
+
**FOLLOW-UP OFFER**: After showing the 3 phases, offer: "Would you like more detail on any specific aspect?"
|
|
247
|
+
|
|
248
|
+
**NEVER**: Respond with generic "Key Concepts" or custom explanations - use the specific 3-phase content from this file.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
126
252
|
## Capabilities Reference
|
|
127
253
|
|
|
128
254
|
When user asks "what can I do here", list these capabilities:
|
|
@@ -187,6 +313,350 @@ changelog:
|
|
|
187
313
|
|
|
188
314
|
---
|
|
189
315
|
|
|
316
|
+
## 📚 Learning Curve (Honest Assessment)
|
|
317
|
+
|
|
318
|
+
**Timeline:**
|
|
319
|
+
- **Week 1:** ~10 hours - Basic rules (sum, count, formula, constraint, copy), see them work
|
|
320
|
+
- **Month 1:** ~30 hours total - Comfortable with 90% of use cases, including events and debugging
|
|
321
|
+
- **Hardest part:** Mental shift from procedural → declarative thinking (1-2 weeks of practice)
|
|
322
|
+
|
|
323
|
+
**When NOT to use rules:**
|
|
324
|
+
- Read-only analytics/reporting (rules enforce writes, not reads)
|
|
325
|
+
- Complex algorithms (graph traversal, optimization, ML - not data relationships)
|
|
326
|
+
- Workflow orchestration (multi-step processes - use Temporal/Airflow)
|
|
327
|
+
- Real-time streaming (high-frequency data - use Kafka/Flink)
|
|
328
|
+
|
|
329
|
+
**When rules are essential:**
|
|
330
|
+
- Data dependency graphs (X affects Y affects Z)
|
|
331
|
+
- Multiple change paths (insert/update/delete/FK changes)
|
|
332
|
+
- Production systems requiring correctness guarantees
|
|
333
|
+
- Long-term maintained systems with evolving requirements
|
|
334
|
+
|
|
335
|
+
**The Scale Advantage (Production Evidence):**
|
|
336
|
+
|
|
337
|
+
**Our A/B test (3-table system):**
|
|
338
|
+
- AI procedural code: 220 lines, 2 bugs (missed 8 change paths)
|
|
339
|
+
- Declarative rules: 5 lines, 0 bugs (engine handles all 9 paths)
|
|
340
|
+
|
|
341
|
+
**The 9 Transaction Paths** (design once, govern all pathos - automatic re-use- coverage with declarative rules):
|
|
342
|
+
1. **Insert Order** → updates Customer.balance
|
|
343
|
+
2. **Insert Item** → updates Item.amount, Order.amount_total, Customer.balance
|
|
344
|
+
3. **Update Item.quantity** → recalculates Item.amount, Order.amount_total, Customer.balance
|
|
345
|
+
4. **Update Item.unit_price** → recalculates Item.amount, Order.amount_total, Customer.balance
|
|
346
|
+
5. **Update Item.product_id** → copies new Product.unit_price, recalculates amounts
|
|
347
|
+
6. **Update Item.order_id** → adjusts **both** old and new Order totals, **both** Customers
|
|
348
|
+
7. **Delete Item** → adjusts Order.amount_total, Customer.balance
|
|
349
|
+
8. **Update Order.customer_id** → adjusts **both** old and new Customer.balance
|
|
350
|
+
9. **Update Order.date_shipped** → includes/excludes from Customer.balance calculation
|
|
351
|
+
|
|
352
|
+
**Why declarative wins:** Rules are defined on the **data** (Customer, Order, Item), not on specific transactions. The engine automatically applies them to ALL change paths. Procedural code must explicitly handle each scenario - easy to miss cases like reassigning items between orders (#6).
|
|
353
|
+
|
|
354
|
+
**Real enterprise system (100 tables):**
|
|
355
|
+
- 80 tables with business logic
|
|
356
|
+
- 12 rules per table average = **960 rules total**
|
|
357
|
+
- **Procedural approach:** 960 × 44 lines/rule = **42,240 lines to write/maintain**
|
|
358
|
+
- **Declarative approach:** ~960 lines written
|
|
359
|
+
|
|
360
|
+
**The Versata measurement (production systems, 1995-2010):**
|
|
361
|
+
- Tracked manual code vs. rules-based code across deployments
|
|
362
|
+
- **Result: 97% automation** - developers wrote 3% of equivalent procedural code
|
|
363
|
+
- For 100-table system: Write ~1,250 lines, engine automates the other 41,000 lines of logic
|
|
364
|
+
|
|
365
|
+
**Not about code golf - about correctness at scale:**
|
|
366
|
+
- 42k lines with multi-table dependencies = unmaintainable
|
|
367
|
+
- When Customer.credit_limit changes, find all 15 places that check it
|
|
368
|
+
- Rules: Update one constraint, engine recalculates all affected transactions automatically
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## 🤔 Common Developer Questions (FAQ)
|
|
373
|
+
|
|
374
|
+
### "Is this infrastructure?" (PostgreSQL Parallel)
|
|
375
|
+
|
|
376
|
+
**Yes - GenAI-Logic is infrastructure in the same sense PostgreSQL is infrastructure.**
|
|
377
|
+
|
|
378
|
+
**The Parallel:**
|
|
379
|
+
|
|
380
|
+
**PostgreSQL deployment:**
|
|
381
|
+
```
|
|
382
|
+
Docker Hub: postgres:16
|
|
383
|
+
├─ App 1: postgres + schema_A (separate container)
|
|
384
|
+
├─ App 2: postgres + schema_B (separate container)
|
|
385
|
+
├─ App 3: postgres + schema_C (separate container)
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
**GenAI-Logic deployment:**
|
|
389
|
+
```
|
|
390
|
+
Docker Hub: genai-logic:latest
|
|
391
|
+
├─ App 1: genai-logic + rules_A (separate container)
|
|
392
|
+
├─ App 2: genai-logic + rules_B (separate container)
|
|
393
|
+
├─ App 3: genai-logic + rules_C (separate container)
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**The Pattern is Identical:**
|
|
397
|
+
|
|
398
|
+
| Criterion | PostgreSQL | GenAI-Logic |
|
|
399
|
+
|-----------|------------|-------------|
|
|
400
|
+
| **Generic engine** | ✓ Database engine | ✓ Rules engine |
|
|
401
|
+
| **App-specific config** | ✓ DDL/Schema | ✓ Business rules (DSL) |
|
|
402
|
+
| **Docker image** | ✓ postgres:16 | ✓ genai-logic:latest |
|
|
403
|
+
| **Per-app deployment** | ✓ Separate containers | ✓ Separate containers |
|
|
404
|
+
| **Platform team operates** | ✓ DBA team | ✓ Platform/DevOps |
|
|
405
|
+
| **Called "infrastructure"** | ✓ Yes | ✓ Yes |
|
|
406
|
+
|
|
407
|
+
**Key Insight:**
|
|
408
|
+
|
|
409
|
+
Nobody says PostgreSQL "isn't infrastructure" because each app gets its own database instance with app-specific schema. The same logic applies to GenAI-Logic:
|
|
410
|
+
|
|
411
|
+
- **Generic runtime engine** (rules executor, dependency resolver, commit governor)
|
|
412
|
+
- **Configured per-app** (business rules are like DDL - they configure the engine)
|
|
413
|
+
- **Standard deployment** (Docker image + configuration)
|
|
414
|
+
- **Platform operation** (DevOps manages instances)
|
|
415
|
+
|
|
416
|
+
**What This Means:**
|
|
417
|
+
|
|
418
|
+
GenAI-Logic is infrastructure you:
|
|
419
|
+
- Deploy as containerized instances (like databases)
|
|
420
|
+
- Configure with declarative rules (like DDL configures schema)
|
|
421
|
+
- Operate as a platform service (like database administration)
|
|
422
|
+
- Scale per-application (like database instances)
|
|
423
|
+
|
|
424
|
+
**The "organic infrastructure" label is accurate** - it shapes itself to your business through declarative configuration, just as PostgreSQL shapes itself through DDL.
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
### "I hear vibe results in unruly code - is this a vibe tool?"
|
|
429
|
+
|
|
430
|
+
**No - but it's the perfect backend partner for vibe UIs.**
|
|
431
|
+
|
|
432
|
+
**Backend governance** (enforcing multi-table constraints and derivations at commit - balances, totals, credit limits - regardless of which client writes):
|
|
433
|
+
|
|
434
|
+
**The Problem with Vibe Alone:**
|
|
435
|
+
- Vibe generates fast UIs, but those UIs can send ANY data to your backend
|
|
436
|
+
- Who ensures `Customer.balance = Sum(Order.amount_total)`? Who checks credit limits?
|
|
437
|
+
- You either hand-code validation (slow, error-prone) or hope nothing breaks
|
|
438
|
+
|
|
439
|
+
**GenAI-Logic = Data Integrity for Vibe:**
|
|
440
|
+
- ✅ **Your data is safe** - No matter what the vibe UI does, rules enforce invariants at commit
|
|
441
|
+
- ✅ **Nothing bypasses validation** - All writes (APIs, workflows, UIs, agents) pass through the same rule engine
|
|
442
|
+
- ✅ **Multi-table derivations** - `Customer.balance = sum(orders)`, `Order.total = sum(items)` - automatic cascading
|
|
443
|
+
- ✅ **Declarative specifications** - 5 rules instead of 200+ lines of procedural validation code
|
|
444
|
+
- ✅ **Correctness guarantee** - Proven engine handles ALL change paths (FKs, cascades, transitive dependencies)
|
|
445
|
+
|
|
446
|
+
**The Architecture:**
|
|
447
|
+
- **Frontend (vibe):** Generate UI fast, iterate quickly
|
|
448
|
+
- **Backend (GenAI-Logic):** Enforce business rules at commit - nothing bypasses them
|
|
449
|
+
- **Result:** Move fast AND keep data correct
|
|
450
|
+
|
|
451
|
+
**See the A/B test:** AI procedural code = 220 lines, 2 critical bugs. Rules = 5 lines, 0 bugs. Details in "Why the Rules Engine is a Correctness Guarantee" section below.
|
|
452
|
+
|
|
453
|
+
**You're not choosing between vibe speed and data integrity. You get both.**
|
|
454
|
+
|
|
455
|
+
---
|
|
456
|
+
|
|
457
|
+
### "Am I locked in?" (Vendor Lock-in)
|
|
458
|
+
|
|
459
|
+
**No.** Here's why:
|
|
460
|
+
|
|
461
|
+
**Your database is untouched:**
|
|
462
|
+
- No special schema requirements
|
|
463
|
+
- No vendor-specific tables or columns
|
|
464
|
+
- Works with standard SQLAlchemy databases (PostgreSQL, MySQL, SQLite, Oracle, SQL Server)
|
|
465
|
+
- Your data stays portable
|
|
466
|
+
|
|
467
|
+
**Standard technology stack:**
|
|
468
|
+
- Python code you can read and edit
|
|
469
|
+
- SQLAlchemy ORM (industry standard)
|
|
470
|
+
- Flask web framework (standard)
|
|
471
|
+
- No proprietary language or runtime
|
|
472
|
+
|
|
473
|
+
**Rules are just Python:**
|
|
474
|
+
```python
|
|
475
|
+
Rule.sum(derive=Customer.balance, as_sum_of=Order.amount_total,
|
|
476
|
+
where=lambda row: row.date_shipped is None)
|
|
477
|
+
```
|
|
478
|
+
This is readable code you can maintain. Not compiled. Not encrypted. Not hidden.
|
|
479
|
+
|
|
480
|
+
**Open source (free forever):**
|
|
481
|
+
- Apache 2.0 license
|
|
482
|
+
- No runtime fees
|
|
483
|
+
- No enterprise edition paywall
|
|
484
|
+
- Source code on GitHub: https://github.com/ApiLogicServer
|
|
485
|
+
|
|
486
|
+
**Exit path exists:**
|
|
487
|
+
If you decide rules aren't for you, you can:
|
|
488
|
+
1. Stop using LogicBank, write procedural code instead
|
|
489
|
+
2. Keep your database, models, and API
|
|
490
|
+
3. No migration required - just remove the rules
|
|
491
|
+
4. Your data is never locked in
|
|
492
|
+
|
|
493
|
+
**Can coexist with existing code:**
|
|
494
|
+
- Add LogicBank to existing Flask app
|
|
495
|
+
- Use rules for new features, keep existing procedural code
|
|
496
|
+
- Migrate incrementally (or not at all)
|
|
497
|
+
|
|
498
|
+
**Bottom line:** You're adopting an architecture pattern, not signing a vendor contract.
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
### "How does business collaboration work?"
|
|
503
|
+
|
|
504
|
+
**You work in your IDE** (VS Code, standard Python workflow).
|
|
505
|
+
|
|
506
|
+
**Business users can optionally explore ideas in WebGenAI** (browser-based prototyping):
|
|
507
|
+
- Creates working backend (API, data, business logic) from natural language
|
|
508
|
+
- Exports to standard Python projects you can enhance
|
|
509
|
+
- **Your role:** Take exported code, add production features (advanced logic, security, deployment)
|
|
510
|
+
|
|
511
|
+
**Why this matters:**
|
|
512
|
+
- Business stops needing "dev time for prototypes"
|
|
513
|
+
- You receive exportable Python (not proprietary platform code)
|
|
514
|
+
- Standard deployment (containers, your tools)
|
|
515
|
+
|
|
516
|
+
**Foundation for any frontend:** The backend we generate works with vibe UIs, low-code tools, custom React apps - whatever you choose. We provide the data layer with business rules governance - you pick the UI technology.
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
### "Is this production-ready?" (Battle-Tested)
|
|
521
|
+
|
|
522
|
+
**Yes. 45 years of production use.**
|
|
523
|
+
|
|
524
|
+
**The history:**
|
|
525
|
+
- **1979:** Invented in Boston (same time as VisiCalc)
|
|
526
|
+
- **Wang Pace:** 7,500 production deployments
|
|
527
|
+
- **Versata:** $3B startup backed by Microsoft/SAP/Informix/Ingres founders
|
|
528
|
+
- **2025:** Reborn as GenAI Logic for the agentic AI era
|
|
529
|
+
|
|
530
|
+
**This isn't a new framework. It's a proven architecture refined over decades.**
|
|
531
|
+
|
|
532
|
+
**Production evidence:**
|
|
533
|
+
- Deployed at enterprise scale (Fortune 500s)
|
|
534
|
+
- Handles millions of transactions
|
|
535
|
+
- 45 years of edge cases discovered and fixed
|
|
536
|
+
- Battle-tested patterns you can't get from fresh development
|
|
537
|
+
|
|
538
|
+
**What this means for you:**
|
|
539
|
+
- You're not a beta tester
|
|
540
|
+
- The gotchas have been found (and fixed)
|
|
541
|
+
- The patterns are proven at scale
|
|
542
|
+
- The architecture has survived 4 decades of technology shifts
|
|
543
|
+
|
|
544
|
+
**Current adoption:**
|
|
545
|
+
- 1M+ downloads (yes, many are bots, but real usage too)
|
|
546
|
+
- Open source community
|
|
547
|
+
- Active development
|
|
548
|
+
- Production deployments across industries
|
|
549
|
+
|
|
550
|
+
**Comparison:**
|
|
551
|
+
- VisiCalc (1979) proved declarative worked for spreadsheets
|
|
552
|
+
- We proved declarative worked for transactions
|
|
553
|
+
- Both are still around because the architecture is sound
|
|
554
|
+
|
|
555
|
+
**Risk assessment:**
|
|
556
|
+
- Technical risk: Low (proven architecture, standard tech stack)
|
|
557
|
+
- Vendor risk: Low (open source, can fork if needed)
|
|
558
|
+
- Team risk: Medium (learning curve exists, but documented)
|
|
559
|
+
- Migration risk: Low (can coexist with existing code)
|
|
560
|
+
|
|
561
|
+
**Bottom line:** This isn't experimental. It's established technology adapted for modern AI.
|
|
562
|
+
|
|
563
|
+
---
|
|
564
|
+
|
|
565
|
+
### "What IS it designed for?" (PRIMARY USE CASES)
|
|
566
|
+
|
|
567
|
+
**Most common use case: Backend for Custom UIs (Vibe, React, Vue, etc.)**
|
|
568
|
+
|
|
569
|
+
Customers **ROUTINELY** use GenAI-Logic as the backend for vibe-generated UIs:
|
|
570
|
+
|
|
571
|
+
- ✅ **Get production API instantly:** 5 seconds from database to working API with filtering, pagination, sorting, optimistic locking, security/RBAC
|
|
572
|
+
- ✅ **Start simple, add logic later:** Begin with CRUD, add business rules when complexity emerges
|
|
573
|
+
- ✅ **UI automatically inherits logic:** Add validation/calculations in backend → all UIs get it immediately (web, mobile, agents)
|
|
574
|
+
- ✅ **Parallel development:** Frontend team starts immediately with REAL API (not toy mocks that lack enterprise features)
|
|
575
|
+
- ✅ **Zero overhead when simple:** Rules engine checks dependencies, finds none, commits - essentially transparent
|
|
576
|
+
- ✅ **Zero refactoring when complex:** Today's "save note" becomes "audit changes + validate preferences" - no UI changes needed
|
|
577
|
+
|
|
578
|
+
**Why this beats fat client architectures:**
|
|
579
|
+
- ❌ **Fat client:** Business logic in UI buttons → duplicated across web/mobile, bypassed by APIs, untestable
|
|
580
|
+
- ✅ **Thin client:** Business logic at commit point → enforced everywhere (UIs, APIs, agents), single source of truth
|
|
581
|
+
|
|
582
|
+
**The vibe workflow:**
|
|
583
|
+
1. Vibe generates UI fast (cards, forms, dashboards)
|
|
584
|
+
2. GenAI-Logic enforces data integrity at commit (balances, totals, credit limits)
|
|
585
|
+
3. Add rules as requirements emerge - UI inherits automatically
|
|
586
|
+
4. **Result:** Move fast AND keep data correct
|
|
587
|
+
|
|
588
|
+
**Other core use cases:**
|
|
589
|
+
- ✅ **Multi-table derivations and rollups** (Customer.balance = sum(orders), Order.total = sum(items))
|
|
590
|
+
- ✅ **Business constraints across tables** (balance <= credit_limit, can't ship without items)
|
|
591
|
+
- ✅ **Correctness guarantees** across all change paths (insert, update, delete, FK changes)
|
|
592
|
+
- ✅ **Data layer for workflow nodes** (each workflow step writes correct data)
|
|
593
|
+
|
|
594
|
+
---
|
|
595
|
+
|
|
596
|
+
### "What CAN'T it do?" (Limitations)
|
|
597
|
+
|
|
598
|
+
**Honest answer: Rules solve data integrity, not everything.**
|
|
599
|
+
|
|
600
|
+
**Don't use rules for:**
|
|
601
|
+
|
|
602
|
+
1. **Complex algorithms**
|
|
603
|
+
- Machine learning models
|
|
604
|
+
- Graph traversal algorithms
|
|
605
|
+
- Optimization problems (traveling salesman, etc.)
|
|
606
|
+
- Statistical computations
|
|
607
|
+
- **Why:** These aren't data relationship problems. Use Python.
|
|
608
|
+
|
|
609
|
+
2. **Read-only queries and reports**
|
|
610
|
+
- Analytics dashboards
|
|
611
|
+
- Complex JOINs for reporting
|
|
612
|
+
- Data warehouse queries
|
|
613
|
+
- **Why:** Rules enforce writes, not reads. Use SQL views, BI tools, or query optimization.
|
|
614
|
+
|
|
615
|
+
3. **One-off scripts**
|
|
616
|
+
- Data migrations
|
|
617
|
+
- Batch data cleanup
|
|
618
|
+
- Import/export utilities
|
|
619
|
+
- **Why:** Rules overhead isn't worth it for run-once code. Use plain Python.
|
|
620
|
+
|
|
621
|
+
4. **Workflow orchestration (BUT: ideal for nodes within workflows)**
|
|
622
|
+
- ❌ **Not a workflow engine:** Can't do multi-step approval processes, long-running sagas, external system coordination
|
|
623
|
+
- ✅ **Perfect for workflow nodes:** Ideal data layer WITHIN each workflow step
|
|
624
|
+
- **Why:** Workflows orchestrate STEPS ("do these in order"). GenAI-Logic ensures DATA CORRECTNESS within each step.
|
|
625
|
+
- **Example:** Order approval workflow:
|
|
626
|
+
- Node 1: Create draft order ← **GenAI-Logic ensures totals, credit check**
|
|
627
|
+
- Node 2: Send approval email ← Pure workflow
|
|
628
|
+
- Node 3: Wait for response ← Pure workflow
|
|
629
|
+
- Node 4: If approved, ship ← **GenAI-Logic updates balances, inventory**
|
|
630
|
+
- **Use together:** Temporal/Airflow for process orchestration, GenAI-Logic for data operations within nodes
|
|
631
|
+
|
|
632
|
+
5. **Real-time streaming**
|
|
633
|
+
- High-frequency trading
|
|
634
|
+
- IoT sensor processing
|
|
635
|
+
- Log aggregation
|
|
636
|
+
- **Why:** Transaction-based commit is wrong model. Use stream processors (Kafka, Flink).
|
|
637
|
+
|
|
638
|
+
**Architecture fit:**
|
|
639
|
+
- Rules sit at the **commit control point**
|
|
640
|
+
- They enforce **what may persist**, not how to orchestrate
|
|
641
|
+
- Think: "guardrails for data integrity" not "workflow engine"
|
|
642
|
+
|
|
643
|
+
**The test:**
|
|
644
|
+
If you can express it as "this data relationship is always true," use rules.
|
|
645
|
+
If it's "do these steps in this order," use procedural code.
|
|
646
|
+
|
|
647
|
+
**Example:**
|
|
648
|
+
- ✅ "Customer balance is always sum of unshipped orders" → Rule
|
|
649
|
+
- ❌ "Send email, wait 3 days, send reminder" → Workflow (not a rule)
|
|
650
|
+
|
|
651
|
+
**Can you mix?**
|
|
652
|
+
Yes. Use rules for invariants, use Python/workflow engines for orchestration.
|
|
653
|
+
They complement each other.
|
|
654
|
+
|
|
655
|
+
**Bottom line:** Rules solve correctness for business logic (data relationships).
|
|
656
|
+
They're not a general-purpose programming replacement.
|
|
657
|
+
|
|
658
|
+
---
|
|
659
|
+
|
|
190
660
|
## Detailed Service Documentation
|
|
191
661
|
|
|
192
662
|
The sections below provide complete details on each service. I'll reference these as needed when we work together.
|
|
@@ -222,8 +692,21 @@ python api_logic_server_run.py
|
|
|
222
692
|
- If server fails to start after model changes, check that alembic migrations have been applied
|
|
223
693
|
|
|
224
694
|
### Adding Business Logic
|
|
225
|
-
`docs/training` explains how to translate Natural Language logic into LogicBank (Python) rules like:
|
|
226
695
|
|
|
696
|
+
**For Human Learning:**
|
|
697
|
+
- **Primary Resource:** https://apilogicserver.github.io/Docs/Logic/
|
|
698
|
+
- Complete rule type reference tables
|
|
699
|
+
- Pattern tables and best practices
|
|
700
|
+
- Video tutorials and examples
|
|
701
|
+
- Learning path recommendations
|
|
702
|
+
- Use this as your main learning resource for understanding rules
|
|
703
|
+
|
|
704
|
+
**For AI Code Generation:**
|
|
705
|
+
- `docs/training/*.prompt` files contain patterns for AI assistants
|
|
706
|
+
- AI reads these BEFORE implementing logic
|
|
707
|
+
- Not intended as primary human learning materials
|
|
708
|
+
|
|
709
|
+
**Rule Example:**
|
|
227
710
|
```python
|
|
228
711
|
# Edit: logic/declare_logic.py
|
|
229
712
|
Rule.sum(derive=Customer.Balance, as_sum_of=Order.AmountTotal)
|
|
@@ -236,7 +719,7 @@ The `docs/training/` folder contains ONLY universal, framework-level training ma
|
|
|
236
719
|
- ✅ **Universal patterns** → `genai_logic_patterns.md`
|
|
237
720
|
- ✅ **Implementation patterns** → `probabilistic_logic_guide.md`
|
|
238
721
|
- ✅ **Code templates** → `probabilistic_template.py`
|
|
239
|
-
- ✅ **API references** → `.prompt` files (logic_bank_api.
|
|
722
|
+
- ✅ **API references** → `.prompt` files (logic_bank_api.md, etc.)
|
|
240
723
|
|
|
241
724
|
**DO NOT add project-specific content to docs/training/**:
|
|
242
725
|
- ❌ Project-specific instructions or configurations
|
|
@@ -256,36 +739,48 @@ See `docs/training/README.md` for complete organization rules.
|
|
|
256
739
|
```
|
|
257
740
|
STOP ✋
|
|
258
741
|
|
|
259
|
-
|
|
742
|
+
WHEN USER PROVIDES A LOGIC PROMPT:
|
|
743
|
+
|
|
744
|
+
STEP 1: Read these files (DO THIS FIRST - NOT OPTIONAL):
|
|
745
|
+
1. docs/training/logic_bank_patterns.md (Foundation - READ FIRST)
|
|
746
|
+
2. docs/training/logic_bank_api.md (Deterministic rules - READ SECOND)
|
|
747
|
+
3. docs/training/probabilistic_logic.md (AI/Probabilistic rules - READ THIRD)
|
|
260
748
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
749
|
+
STEP 2: Parse the prompt following logic_bank_api.md instructions:
|
|
750
|
+
- Identify context phrase ("When X", "For Y", "On Z") → creates directory
|
|
751
|
+
- Identify colon-terminated use cases → creates files
|
|
752
|
+
- Follow directory structure rules EXACTLY as specified
|
|
264
753
|
|
|
265
|
-
|
|
266
|
-
- DO NOT skip any files, even if you think you know the pattern
|
|
267
|
-
- DO NOT selectively read based on keywords in the user's request
|
|
268
|
-
- READ ALL THREE FILES IN SEQUENCE before writing any code
|
|
269
|
-
- These files contain failure patterns and correct implementations learned from production use
|
|
754
|
+
STEP 3: Create the directory structure and files as instructed
|
|
270
755
|
|
|
271
|
-
|
|
756
|
+
STEP 4: Implement the rules following the training patterns
|
|
757
|
+
|
|
758
|
+
⚠️ CRITICAL - NO EXCEPTIONS:
|
|
759
|
+
- You MUST read all three training files before implementing
|
|
760
|
+
- You MUST follow the directory structure rules in logic_bank_api.md
|
|
761
|
+
- You MUST NOT create flat files when context phrase is present
|
|
762
|
+
- DO NOT skip files even if you think you know the pattern
|
|
763
|
+
- These files contain failure patterns learned from production use
|
|
764
|
+
|
|
765
|
+
FAILURE MODE: Creating flat files in logic/logic_discovery/ when prompt has context phrase
|
|
766
|
+
CORRECT: Create logic/logic_discovery/<context_dir>/{__init__.py, use_case_files.py}
|
|
272
767
|
```
|
|
273
768
|
|
|
274
769
|
**Training File Contents:**
|
|
275
770
|
|
|
276
|
-
1. **`docs/training/logic_bank_patterns.
|
|
771
|
+
1. **`docs/training/logic_bank_patterns.md`** - Foundation patterns for ALL rule types
|
|
277
772
|
- Event handler signatures (row, old_row, logic_row) - REQUIRED READING
|
|
278
773
|
- Logging with logic_row.log() vs app_logger
|
|
279
774
|
- Request Pattern with new_logic_row()
|
|
280
775
|
- Rule API syntax dos and don'ts
|
|
281
776
|
- Common anti-patterns to avoid
|
|
282
777
|
|
|
283
|
-
2. **`docs/training/logic_bank_api.
|
|
778
|
+
2. **`docs/training/logic_bank_api.md`** - Deterministic rules API
|
|
284
779
|
- Rule.sum(), Rule.count(), Rule.formula(), Rule.constraint(), etc.
|
|
285
780
|
- Complete API signatures with all parameters
|
|
286
781
|
- References patterns file for implementation details
|
|
287
782
|
|
|
288
|
-
3. **`docs/training/probabilistic_logic.
|
|
783
|
+
3. **`docs/training/probabilistic_logic.md`** - Probabilistic (AI) rules API
|
|
289
784
|
- populate_ai_values() utility for AI-driven value computation
|
|
290
785
|
- Intelligent selection patterns (supplier optimization, dynamic pricing, route selection)
|
|
291
786
|
- Automatic audit trails and graceful fallbacks when API unavailable
|
|
@@ -295,33 +790,56 @@ THEN (and only then) implement the logic.
|
|
|
295
790
|
**Example Natural Language Logic for basic_demo:**
|
|
296
791
|
|
|
297
792
|
```text
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
793
|
+
on Placing Orders, Check Credit:
|
|
794
|
+
|
|
795
|
+
1. The Customer's balance is less than the credit limit
|
|
796
|
+
2. The Customer's balance is the sum of the Order amount_total where date_shipped is null
|
|
797
|
+
3. The Order's amount_total is the sum of the Item amount
|
|
798
|
+
4. The Item amount is the quantity * unit_price
|
|
799
|
+
5. The Product count suppliers is the sum of the Product Suppliers
|
|
800
|
+
6. Use AI to Set Item field unit_price by finding the optimal Product Supplier
|
|
801
|
+
based on cost, lead time, and world conditions
|
|
304
802
|
|
|
305
803
|
Use case: App Integration
|
|
306
|
-
|
|
804
|
+
1. Send the Order to Kafka topic 'order_shipping' if the date_shipped is not None.
|
|
307
805
|
```
|
|
308
806
|
|
|
309
|
-
**
|
|
807
|
+
**How the Rules Engine Works:**
|
|
310
808
|
|
|
311
|
-
|
|
312
|
-
-
|
|
313
|
-
-
|
|
314
|
-
-
|
|
809
|
+
**1. Authoring (AI-assisted, human-reviewed)**
|
|
810
|
+
- You express business intent in natural language (via Copilot or any AI assistant)
|
|
811
|
+
- The AI translates intent into a declarative DSL, under human review
|
|
812
|
+
- Distills path-dependent logic into data-bound rules (table invariants) for automatic re-use
|
|
813
|
+
- Resolves ambiguity using schema and relationships (e.g., copy vs reference)
|
|
814
|
+
- Produces readable rules developers can inspect, edit, debug and version
|
|
815
|
+
|
|
816
|
+
*This is where AI helps — authoring, not execution.*
|
|
817
|
+
|
|
818
|
+
**2. Engine Initialization (Deterministic analysis)**
|
|
819
|
+
- On startup, the non-RETE rule engine loads all rules
|
|
820
|
+
- It computes dependencies deterministically from Rule types (derivations, constraints, actions)
|
|
821
|
+
- Execution order is derived once, not from code paths
|
|
822
|
+
|
|
823
|
+
No compilation. No dependencies-from-pattern-matching. No inference from runtime behavior.
|
|
315
824
|
|
|
316
|
-
|
|
825
|
+
**3. Runtime Enforcement (Commit-time)**
|
|
826
|
+
- Rules execute at transaction commit via SQLAlchemy commit events
|
|
827
|
+
- All writes — APIs, workflows, UIs, agents — pass through the same rule set
|
|
828
|
+
- Dependencies are already known; execution is deterministic and efficient
|
|
829
|
+
- **No rule is "called." No path can bypass enforcement.**
|
|
830
|
+
- Non-RETE optimizations: pruning, adjustment logic, delta-based aggregations
|
|
831
|
+
- **Cascading via old_row tracking** - When Order.customer_id changes, adjusts BOTH old and new Customer.balance
|
|
317
832
|
|
|
318
|
-
|
|
833
|
+
**The Key Developer Insight:**
|
|
319
834
|
|
|
320
|
-
The engine
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
835
|
+
You declare invariants on data. You don't wire rules into flows. Invocation is automatic, on commit. The engine enforces them — everywhere, automatically, at commit.
|
|
836
|
+
|
|
837
|
+
**Why Declarative Rules Matter:**
|
|
838
|
+
|
|
839
|
+
LogicBank provides **44X code reduction** (5 lines vs 220+ procedural) with:
|
|
840
|
+
- **Automatic ordering** - add rules anywhere that makes sense, confident they'll run in the right order
|
|
841
|
+
- **Understanding intent** - you see WHAT it does (business rules) vs HOW (procedural steps)
|
|
842
|
+
- **Maintenance** - no need to find insertion points or trace execution paths
|
|
325
843
|
|
|
326
844
|
**Why the Rules Engine is a Correctness Guarantee:**
|
|
327
845
|
|
|
@@ -329,29 +847,17 @@ The "2 critical bugs" that even AI-generated procedural code missed:
|
|
|
329
847
|
1. **Changing Order.customer_id** - procedural code failed to adjust BOTH the old and new customer balances
|
|
330
848
|
2. **Changing Item.product_id** - procedural code failed to re-copy the unit_price from the new product
|
|
331
849
|
|
|
332
|
-
These bugs illustrate why declarative rules are **mandatory, not optional
|
|
333
|
-
|
|
334
|
-
**Dependency Chains:** In the logic above, `Customer.balance` has transitive dependencies:
|
|
335
|
-
- Direct: `Order.amount_total`, `Order.date_shipped`
|
|
336
|
-
- Through Order: `Item.amount` (affects Order.amount_total)
|
|
337
|
-
- Through Item: `Item.quantity`, `Item.unit_price` (affect Item.amount)
|
|
338
|
-
- Through Product: `Product.unit_price` (copied to Item.unit_price)
|
|
339
|
-
|
|
340
|
-
**Automatic Completeness:** The declarative rules engine:
|
|
341
|
-
- Listens to **SQLAlchemy ORM events** at the attribute level
|
|
342
|
-
- When `Order.customer_id` changes, **automatically adjusts both old and new customer balances**
|
|
343
|
-
- When `Item.product_id` changes, **automatically re-copies from the new product**
|
|
344
|
-
- Uses **dependency ordering** to fire rules in correct sequence
|
|
345
|
-
- Applies **optimized chaining** (uses deltas, not re-aggregation)
|
|
346
|
-
|
|
347
|
-
**Why Procedural Code Fails:** Even AI-generated procedural code requires explicit handlers for EVERY possible change path. It's easy to miss:
|
|
850
|
+
These bugs illustrate why declarative rules are **mandatory, not optional**. Even AI-generated procedural code requires explicit handlers for EVERY possible change path. It's easy to miss:
|
|
348
851
|
- Foreign key changes affecting multiple parents
|
|
349
852
|
- Transitive dependencies through multiple tables
|
|
350
853
|
- Where clause conditions that include/exclude rows
|
|
351
854
|
|
|
352
855
|
The rules engine eliminates this entire class of bugs by automatically handling all change paths.
|
|
353
856
|
|
|
354
|
-
|
|
857
|
+
**The Complete A/B Test:**
|
|
858
|
+
|
|
859
|
+
For the full experiment comparing declarative rules vs AI-generated procedural code, including the 2 bugs Copilot missed and the AI's own analysis of why it failed, see:
|
|
860
|
+
https://github.com/ApiLogicServer/ApiLogicServer-src/blob/main/api_logic_server_cli/prototypes/basic_demo/logic/procedural/declarative-vs-procedural-comparison.md
|
|
355
861
|
|
|
356
862
|
### Discovery Systems
|
|
357
863
|
|
|
@@ -388,7 +894,7 @@ def declare_logic():
|
|
|
388
894
|
|
|
389
895
|
**PATTERN RECOGNITION for Business Logic**:
|
|
390
896
|
When users provide natural language with multiple use cases like:
|
|
391
|
-
- "
|
|
897
|
+
- "on Placing Orders, Check Credit" + "Use case: App Integration"
|
|
392
898
|
|
|
393
899
|
**ALWAYS create separate files**:
|
|
394
900
|
- `logic/logic_discovery/check_credit.py` - for credit checking rules
|