ApiLogicServer 15.2.3__py3-none-any.whl → 15.2.10__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 +3 -1
- api_logic_server_cli/prototypes/base/.github/.copilot-instructions.md +114 -52
- api_logic_server_cli/prototypes/base/docs/training/testing.md +95 -9
- api_logic_server_cli/prototypes/base/test/api_logic_server_behave/behave_logic_report.py +19 -6
- api_logic_server_cli/prototypes/basic_demo/.github/.copilot-instructions.md +744 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/logic/declare_logic.py +17 -1
- api_logic_server_cli/prototypes/basic_demo/readme.md +13 -5
- api_logic_server_cli/prototypes/basic_demo/tutor.md +1436 -0
- api_logic_server_cli/prototypes/manager/.github/.copilot-instructions.md +50 -23
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/.github/.copilot-instructions.md +3 -0
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/customizations/logic/declare_logic.py +17 -1
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/docs/training/testing.md +95 -9
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/iteration/logic/declare_logic.py +17 -1
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/logic/declare_logic.py +38 -1
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/features/order_processing.feature +59 -50
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/features/steps/order_processing_steps.py +395 -248
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/behave.log +66 -62
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Carbon_Neutral_Discount_A.log +51 -41
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Change_Order_Customer.log +29 -0
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Change_Product_in_Item.log +35 -0
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Delete_Item_Reduces_Order.log +39 -19
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Exceed_Credit_Limit_Rejec.log +36 -45
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Good_Order_Placed_via_B2B.log +50 -40
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Item_Quantity_Change.log +33 -0
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Multi-Item_Order_via_B2B_.log +67 -0
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Ship_Order_Excludes_from_.log +24 -14
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Transaction_Processing.log +26 -17
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/logs/scenario_logic_logs/Unship_Order_Includes_in_.log +24 -14
- api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/test/api_logic_server_behave/reports/Behave Logic Report.md +361 -146
- api_logic_server_cli/prototypes/manager/system/ApiLogicServer-Internal-Dev/copilot-dev-context.md +270 -2
- {apilogicserver-15.2.3.dist-info → apilogicserver-15.2.10.dist-info}/METADATA +25 -16
- {apilogicserver-15.2.3.dist-info → apilogicserver-15.2.10.dist-info}/RECORD +36 -30
- {apilogicserver-15.2.3.dist-info → apilogicserver-15.2.10.dist-info}/WHEEL +0 -0
- {apilogicserver-15.2.3.dist-info → apilogicserver-15.2.10.dist-info}/entry_points.txt +0 -0
- {apilogicserver-15.2.3.dist-info → apilogicserver-15.2.10.dist-info}/licenses/LICENSE +0 -0
- {apilogicserver-15.2.3.dist-info → apilogicserver-15.2.10.dist-info}/top_level.txt +0 -0
api_logic_server_cli/prototypes/manager/system/ApiLogicServer-Internal-Dev/copilot-dev-context.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Context Restoration for BLT Manager Workspace
|
|
3
|
+
Description: Re-establishes AI assistant context after BLT regenerates workspace
|
|
4
|
+
Source: ApiLogicServer-src/prototypes/manager/system/ApiLogicServer-Internal-Dev/copilot-dev-context.md
|
|
5
|
+
Propagation: BLT process → Manager workspace
|
|
6
|
+
Usage: AI assistants read this to understand project structure, development workflow, and recent additions
|
|
7
|
+
version: 2.0
|
|
8
|
+
changelog:
|
|
9
|
+
- 2.0 (Oct 2025) - Added AI-Guided Training section (tutor.md v2.0, OBX improvements, design philosophy)
|
|
10
|
+
- 1.0 (Initial) - Established workspace structure, GenAI prompt engineering, development workflow
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# Context Restoration: BLT Manager Workspace
|
|
2
14
|
|
|
3
15
|
**Purpose:** This file re-establishes AI assistant context after BLT runs regenerate this workspace.
|
|
@@ -83,7 +95,7 @@ This document contains **everything** you need to understand the system:
|
|
|
83
95
|
|
|
84
96
|
### For Working Within Created Projects:
|
|
85
97
|
- **Project-level `.copilot-instructions.md`** - How to EXTEND/CUSTOMIZE projects (auto-generated in each project)
|
|
86
|
-
- **Location:** `prototypes/base/.github/.copilot-instructions.md` (template)
|
|
98
|
+
- **Location:** `prototypes/base/.github/.copilot-instructions.md` (template) and `prototypes/basic_demo/.github/.copilot-instructions.md` (tutorial version)
|
|
87
99
|
- **Size:** ~740 lines
|
|
88
100
|
- **Scope:** Complete architecture guide for EACH created project
|
|
89
101
|
- **Purpose:** 13 Main Services (what AI can do in a project):
|
|
@@ -101,7 +113,12 @@ This document contains **everything** you need to understand the system:
|
|
|
101
113
|
12. **Adding Events** - Row events for integrations (Kafka, webhooks, etc.)
|
|
102
114
|
13. **Critical Patterns** - React component best practices, null-safe constraints, test repeatability
|
|
103
115
|
- ⚠️ **CRITICAL:** These are TWO DIFFERENT FILES - never replace the per-project version with the manager version!
|
|
104
|
-
- 🚨 **PROPAGATION PROBLEM:** Changes to project-level instructions must be carefully copied to `prototypes/base/.github/.copilot-instructions.md`
|
|
116
|
+
- 🚨 **PROPAGATION PROBLEM:** Changes to project-level instructions must be carefully copied to both `prototypes/base/.github/.copilot-instructions.md` AND `prototypes/basic_demo/.github/.copilot-instructions.md`
|
|
117
|
+
- 📋 **OBX PATTERN (v2.3, Oct 2025):** Use **positive instructions** for AI behavior:
|
|
118
|
+
- ✅ **Works:** "When user asks to read instructions, respond with the Welcome section content below"
|
|
119
|
+
- ❌ **Fails:** "Do NOT add preamble" or relying on structure alone
|
|
120
|
+
- **Theory:** Tell AI what TO do, not what NOT to do
|
|
121
|
+
- **Result:** Clean welcome message without meta-commentary ("I've read the instructions...")
|
|
105
122
|
- **`docs/training/logic_bank_api.prompt`** - LogicBank API reference (Rosetta Stone for rules)
|
|
106
123
|
- **`docs/training/testing.md`** - Behave testing guide (1755 lines, read BEFORE creating tests)
|
|
107
124
|
|
|
@@ -110,6 +127,77 @@ This document contains **everything** you need to understand the system:
|
|
|
110
127
|
- **[Installation Guide](https://apilogicserver.github.io/Docs/Install/)** - Setup procedures
|
|
111
128
|
- **[Tutorial](https://apilogicserver.github.io/Docs/Tutorial/)** - Step-by-step learning
|
|
112
129
|
|
|
130
|
+
### For AI-Guided Training (New Feature):
|
|
131
|
+
- **`basic_demo/tutor.md`** - AI assistant guide for conducting 30-45 min hands-on tour
|
|
132
|
+
- **Version:** 2.0 (762 lines, October 2025)
|
|
133
|
+
- **Purpose:** "Message in a bottle" for AI assistants - enables guided discovery learning
|
|
134
|
+
- **Method:** Provocation-based (e.g., "how did it know ORDER has a foreign key to Customer?")
|
|
135
|
+
- **Philosophy:** Users learn by DOING (hands-on tour), not reading docs or taking quizzes (Versata approach)
|
|
136
|
+
- **Structure:** 9 sections with timing checkpoints (15 min, 35 min), concrete metrics (48 vs 200+ lines)
|
|
137
|
+
- **Key Additions in v2.0:** Spreadsheet analogy, procedural comparison (BUG FIX examples), context for schema commands, three ways to add logic (Discovery/IDE/Chat), MCP server integration
|
|
138
|
+
- **Location:** `prototypes/basic_demo/tutor.md` (template), propagates to created `basic_demo` projects
|
|
139
|
+
- **Invocation:** User says "Guide me through basic_demo" → AI reads tutor.md → conducts tour
|
|
140
|
+
|
|
141
|
+
- **Design Philosophy - Why Provocation Over Instruction:**
|
|
142
|
+
- **Problem with traditional training:** PowerPoint → quiz/assessment approach tests memorization, not understanding
|
|
143
|
+
- **Versata insight:** "Stop killing people with PowerPoint; identify critical skills, design lab to DO it"
|
|
144
|
+
- **Discovery learning:** Ask provocative questions that force pattern recognition ("How did it know ORDER references CUSTOMER?")
|
|
145
|
+
- **"Aha moments" over rote learning:** User discovers foreign keys exist, then learns they're essential for multi-table logic
|
|
146
|
+
- **Spreadsheet analogy:** Excel user understands formulas → multi-table database is "Excel for related tables"
|
|
147
|
+
- **AI as training partner DURING the lab:** Not quiz after, not docs before - real-time guidance while doing
|
|
148
|
+
- **Result:** 30-45 min hands-on experience creates deeper understanding than hours of documentation reading
|
|
149
|
+
|
|
150
|
+
- **v1.0 → v2.0 Evolution (Battle-Tested Refinements):**
|
|
151
|
+
- **v1.0 (595 lines):** Initial design based on architecture understanding
|
|
152
|
+
- **Live testing:** User spent "several hours with your cousin testing and revising" actual tours
|
|
153
|
+
- **v2.0 (+506 net lines):** Added based on what users actually needed during tours:
|
|
154
|
+
- **Spreadsheet analogy** - Non-technical users needed familiar mental model
|
|
155
|
+
- **Procedural comparison** - Show 48 vs 200+ lines WITH concrete BUG FIX examples (not just line counts)
|
|
156
|
+
- **Context for commands** - Why `add-cust` exists (schema variability, new users discover structure)
|
|
157
|
+
- **Three ways to add logic** - Discovery file (recommended), IDE autocomplete, or Chat
|
|
158
|
+
- **Timing checkpoints** - 15 min at Security, 35 min at Q&A (helps pace the tour)
|
|
159
|
+
- **MCP server mention** - Claude Desktop integration for external AI access
|
|
160
|
+
- **Best practices** - `logic/logic_discovery/` organization pattern
|
|
161
|
+
- **Short response guidance** - "One idea per interaction" prevents overwhelming new users
|
|
162
|
+
- **Key learning:** Initial version was too instruction-heavy, v2.0 adds more context and concrete examples
|
|
163
|
+
|
|
164
|
+
- **`add-cust` Mechanism for Tutor** - Progressive feature addition during guided tour:
|
|
165
|
+
- **Purpose:** Add pre-built customizations progressively during tour (avoids GenAI unpredictability, ensures working examples)
|
|
166
|
+
- **Battle scars:** Also serves as **error recovery** - if users make mistakes during tour, `add-cust` restores database integrity and gets them back on track
|
|
167
|
+
- **Usage in tutor:** Two `add-cust` commands progressively add features:
|
|
168
|
+
1. **First `add-cust`** (from `customizations/` folder) → adds security (RBAC filters) + check credit logic (5 rules), **restores database to known-good state**
|
|
169
|
+
- `logic/declare_logic.py` has check credit rules (constraint, sums, formula, copy, kafka event)
|
|
170
|
+
- `security/declare_security.py` has role-based filters
|
|
171
|
+
- `database/db.sqlite` restored with clean data
|
|
172
|
+
2. **Second `add-cust`** (from `iteration/` folder) → adds schema change (Product.CarbonNeutral) + discount logic, **handles schema updates cleanly**
|
|
173
|
+
- `logic/declare_logic.py` has check credit rules PLUS discount logic (derive_amount function with 10% discount for CarbonNeutral)
|
|
174
|
+
- `database/db.sqlite` updated with CarbonNeutral column and green products
|
|
175
|
+
- `database/models.py` regenerated with new column
|
|
176
|
+
- **Source location:** `prototypes/manager/samples/basic_demo_sample/` in dev source
|
|
177
|
+
- `customizations/` folder - add-cust #1 contents
|
|
178
|
+
- `iteration/` folder - add-cust #2 contents (superset of #1, includes discount logic)
|
|
179
|
+
- **Propagation flow:**
|
|
180
|
+
1. Dev source: `org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/`
|
|
181
|
+
2. BLT copies to Manager: `build_and_test/ApiLogicServer/samples/basic_demo_sample/`
|
|
182
|
+
3. BLT installs to venv: `venv/.../api_logic_server_cli/prototypes/manager/samples/basic_demo_sample/`
|
|
183
|
+
4. During tutor: `add-cust` executes from venv, copies to user's `basic_demo/` project
|
|
184
|
+
- **Key insight:** `add-cust` is a tutor utility, not a production feature - copies pre-built working examples to demonstrate patterns reliably AND recovers from user errors
|
|
185
|
+
- **Maintenance:** When updating add-cust content:
|
|
186
|
+
- Update `customizations/` for add-cust #1 changes
|
|
187
|
+
- Update `iteration/` for add-cust #2 changes (must include everything from #1 plus new content)
|
|
188
|
+
- Both folders in `prototypes/manager/samples/basic_demo_sample/` (dev source)
|
|
189
|
+
- BLT propagates to venv
|
|
190
|
+
|
|
191
|
+
- **OBX (Out-of-Box Experience) Design** - Manager → Project flow optimization (October 2025):
|
|
192
|
+
- **Manager README:** "🚀 First Time Here? Start with basic_demo" section (clear default path)
|
|
193
|
+
- **Manager .copilot-instructions.md:** "CRITICAL: ALWAYS start" directive (no choices, single path)
|
|
194
|
+
- **Project README:** "🤖 Ready to Explore? Recommended: Guide me through" (guided tour as primary option)
|
|
195
|
+
- **Project .copilot-instructions.md:** "🎯 Most Common Next Steps" (5 succinct items at top)
|
|
196
|
+
- **Goal:** Eliminate friction/choice paralysis, make basic_demo → guided tour the clear default
|
|
197
|
+
- **Problem addressed:** Users didn't automatically know to start with basic_demo, didn't default to guided tour
|
|
198
|
+
- **Solution:** Strengthen every touch point in the journey to push toward the optimal path
|
|
199
|
+
- **Flow:** Install → Open Manager → Create basic_demo → Auto-opens → "Guide me through" → 30-45 min tour
|
|
200
|
+
|
|
113
201
|
|
|
114
202
|
|
|
115
203
|
## 👤 Current Maintainer
|
|
@@ -159,6 +247,186 @@ This document contains **everything** you need to understand the system:
|
|
|
159
247
|
|
|
160
248
|
|
|
161
249
|
|
|
250
|
+
## 🤖 GenAI Prompt Engineering Architecture
|
|
251
|
+
|
|
252
|
+
### Overview: ChatGPT Project Creation Pipeline
|
|
253
|
+
|
|
254
|
+
The `genai-logic create` command uses **fine-tuned ChatGPT** to translate natural language requirements into complete working projects. The system uses **prompt engineering** to surround user input with structured instructions.
|
|
255
|
+
|
|
256
|
+
### Key Locations
|
|
257
|
+
|
|
258
|
+
**Prompt Templates:** `system/genai/prompt_inserts/`
|
|
259
|
+
```
|
|
260
|
+
├── sqlite_inserts.prompt # Main orchestrator for DB creation
|
|
261
|
+
├── sqlite_inserts_model_test_hints.prompt # SQLAlchemy class generation rules
|
|
262
|
+
├── logic_inserts.prompt # LogicBank rule generation
|
|
263
|
+
├── logic_translate.prompt # NL → LogicBank translation (existing DB)
|
|
264
|
+
├── graphics.prompt # Dashboard chart generation
|
|
265
|
+
├── response_format.prompt # WGResult Pydantic schema
|
|
266
|
+
└── web_genai.prompt # WebGenAI-specific (15+ tables)
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Training Examples:** `org_git/ApiLogicServer-src/tests/genai_tests/logic_training/`
|
|
270
|
+
```
|
|
271
|
+
├── genai_demo.prompt # Check Credit + No Empty Orders
|
|
272
|
+
├── ready_flag.prompt # Ready Flag pattern (3 use cases)
|
|
273
|
+
├── emp_depts.prompt # Chain Up: sum salaries, constrain budget
|
|
274
|
+
├── graduate.prompt # Cardinality: counts with thresholds
|
|
275
|
+
├── products.prompt # Qualified Any: severity checks
|
|
276
|
+
├── honor_society.prompt # Complex cardinality with qualified counts
|
|
277
|
+
└── *.txt / *_corrected_prompt.txt # Expected outputs and corrections
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Test Examples:** `system/genai/examples/`
|
|
281
|
+
```
|
|
282
|
+
├── genai_demo/ # Complete example with iterations
|
|
283
|
+
├── airport/ # Complex 10+ table system
|
|
284
|
+
├── emp_depts/ # Simple aggregation pattern
|
|
285
|
+
└── time_tracking_billing/ # Real-world scenario
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### The Prompt Assembly Process
|
|
289
|
+
|
|
290
|
+
**User Input:**
|
|
291
|
+
```
|
|
292
|
+
Create a system with customers, orders, items and products.
|
|
293
|
+
|
|
294
|
+
Use case: Check Credit
|
|
295
|
+
1. Customer.balance <= credit_limit
|
|
296
|
+
2. Customer.balance = Sum(Order.amount_total where date_shipped is null)
|
|
297
|
+
3. Order.amount_total = Sum(Item.amount)
|
|
298
|
+
4. Item.amount = quantity * unit_price
|
|
299
|
+
5. Item.unit_price = copy from Product.unit_price
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
**System Surrounds With:**
|
|
303
|
+
|
|
304
|
+
1. **Model Generation Instructions** (`sqlite_inserts_model_test_hints.prompt`):
|
|
305
|
+
- Use autonum keys for ALL tables (including junction tables)
|
|
306
|
+
- Create classes, never tables (Class names singular, capitalized)
|
|
307
|
+
- **CRITICAL:** "If you create sum, count or formula Logic Bank rules, then you MUST create a corresponding column in the data model"
|
|
308
|
+
- No check constraints (logic uses rules instead)
|
|
309
|
+
- Foreign key columns (not relationship names) for test data
|
|
310
|
+
|
|
311
|
+
2. **Logic Generation Instructions** (`logic_inserts.prompt`):
|
|
312
|
+
- "Use LogicBank to enforce these requirements (do not generate check constraints)"
|
|
313
|
+
- "be sure to update the data model and *all* test data with any attributes used in the logic"
|
|
314
|
+
|
|
315
|
+
3. **Response Structure** (`response_format.prompt`):
|
|
316
|
+
```python
|
|
317
|
+
class WGResult(BaseModel):
|
|
318
|
+
models: List[Model] # SQLAlchemy classes
|
|
319
|
+
rules: List[Rule] # LogicBank declarations
|
|
320
|
+
test_data: str # Python test data creation
|
|
321
|
+
test_data_rows: List[TestDataRow]
|
|
322
|
+
test_data_sqlite: str # INSERT statements
|
|
323
|
+
graphics: List[Graphic] # Dashboard queries
|
|
324
|
+
name: str # Suggested project name
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
**Result:** ChatGPT returns structured JSON with models, rules, and test data that:
|
|
328
|
+
- Has `Customer.balance`, `Order.amount_total`, `Order.item_count` columns created automatically
|
|
329
|
+
- Contains LogicBank rules for all derivations
|
|
330
|
+
- Includes test data with derived attributes pre-initialized
|
|
331
|
+
|
|
332
|
+
### Key Insight: Model + Logic Co-Generation
|
|
333
|
+
|
|
334
|
+
**Unlike existing database projects**, GenAI creation can **modify the data model** to support logic:
|
|
335
|
+
|
|
336
|
+
- **Derived attributes materialize:** `Customer.balance`, `Order.amount_total`, `Product.total_ordered`
|
|
337
|
+
- **Count columns appear:** `Order.item_count` for existence checks
|
|
338
|
+
- **Qualified counts split:** `Product.notice_count` + `Product.severity_five_count`
|
|
339
|
+
|
|
340
|
+
This is why the training examples emphasize:
|
|
341
|
+
> "If you create sum, count or formula Logic Bank rules, then you MUST create a corresponding column in the data model."
|
|
342
|
+
|
|
343
|
+
### Training Pattern Categories
|
|
344
|
+
|
|
345
|
+
The `logic_training/` examples teach ChatGPT these patterns:
|
|
346
|
+
|
|
347
|
+
1. **Chain Up (Aggregation → Constraint)**
|
|
348
|
+
- `emp_depts`: Department.total_salary = sum(Employee.salary); salary <= budget
|
|
349
|
+
- `genai_demo`: Customer.balance = sum(orders); balance <= credit_limit
|
|
350
|
+
|
|
351
|
+
2. **Counts as Existence Checks**
|
|
352
|
+
- `genai_demo`: Order.item_count = count(Items); can't ship if == 0
|
|
353
|
+
- Creates both derivation AND validation
|
|
354
|
+
|
|
355
|
+
3. **Cardinality Patterns (Qualified Any)**
|
|
356
|
+
- `products`: Total notices + severity 5 notices; constraint if orderable
|
|
357
|
+
- `graduate`: Probation count + sick days; constraint for graduation
|
|
358
|
+
- Pattern: Multiple counts (total + qualified) with complex conditions
|
|
359
|
+
|
|
360
|
+
4. **Ready Flag**
|
|
361
|
+
- `ready_flag`: Multi-use-case with conditional aggregations
|
|
362
|
+
- Customer.balance only sums orders where `ready == True AND date_shipped is None`
|
|
363
|
+
- Product.total_ordered only sums items where `ready == True`
|
|
364
|
+
|
|
365
|
+
5. **Chain Down (Copy/Formula)**
|
|
366
|
+
- Item.unit_price = copy(Product.unit_price)
|
|
367
|
+
- Item.ready = Order.ready (formula propagation)
|
|
368
|
+
|
|
369
|
+
### CLI Commands Using This System
|
|
370
|
+
|
|
371
|
+
**Create from natural language:**
|
|
372
|
+
```bash
|
|
373
|
+
genai-logic create --project-name=my_system --using="<natural language>"
|
|
374
|
+
# Internally: assembles prompts → ChatGPT → parses WGResult → generates project
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Translate logic (existing DB):**
|
|
378
|
+
```bash
|
|
379
|
+
genai-logic logic-translate --project-name=. --using-file=docs/logic
|
|
380
|
+
# Uses logic_translate.prompt to convert NL in docs/logic → rules in logic/logic_discovery/
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Fine-Tuning Files
|
|
384
|
+
|
|
385
|
+
**Training Data:** `logic_training/ft.jsonl`
|
|
386
|
+
- JSONL format for ChatGPT fine-tuning
|
|
387
|
+
- Generated from prompt/response pairs
|
|
388
|
+
- ~374KB with all pattern examples
|
|
389
|
+
|
|
390
|
+
**Script:** `logic_training/create_json_l.py`
|
|
391
|
+
- Converts `*.prompt` + `*.txt` → JSONL entries
|
|
392
|
+
- Format: system message, user message (prompt), assistant message (response)
|
|
393
|
+
|
|
394
|
+
### Common Pitfalls (Why Corrections Exist)
|
|
395
|
+
|
|
396
|
+
Several `*_corrected_prompt.txt` files show typical AI mistakes:
|
|
397
|
+
|
|
398
|
+
1. **Wrong cardinality:**
|
|
399
|
+
- `airport.prompt`: Asked for "airplane's passengers" but meant "flight's passengers"
|
|
400
|
+
- AI can't count passengers on an Airplane (no direct relationship)
|
|
401
|
+
- Correction: Count passengers on Flight, constrain by Airplane.seating_capacity
|
|
402
|
+
|
|
403
|
+
2. **Constraint depends on derived flag:**
|
|
404
|
+
- `products.prompt` initially: "product is orderable IF no severity 5 notices"
|
|
405
|
+
- Problem: Makes orderable a derived value, then uses it in constraint
|
|
406
|
+
- Correction: "RAISE ERROR if orderable == True AND has severity 5 notices"
|
|
407
|
+
- Pattern: Flag is input, constraint uses it (not derived from constraint conditions)
|
|
408
|
+
|
|
409
|
+
3. **Negative condition logic:**
|
|
410
|
+
- Must use: `not(row.flag and bad_condition)`
|
|
411
|
+
- Not: `row.flag → requires good_condition` (harder for AI to translate)
|
|
412
|
+
|
|
413
|
+
### Why This Architecture?
|
|
414
|
+
|
|
415
|
+
**Traditional GenAI code generation problems:**
|
|
416
|
+
- Generates 200+ lines of procedural code
|
|
417
|
+
- Misses corner cases (foreign key changes, cascading updates)
|
|
418
|
+
- Creates technical debt (unmaintainable spaghetti)
|
|
419
|
+
|
|
420
|
+
**Declarative GenAI solution:**
|
|
421
|
+
- Generates **specifications** (5 rules), not code (200 lines)
|
|
422
|
+
- Rules executed by proven engine (40+ years, 6,000+ deployments)
|
|
423
|
+
- Engine handles ALL change paths automatically (no corner cases missed)
|
|
424
|
+
- Natural language → DSL → Runtime engine (not NL → procedural code)
|
|
425
|
+
|
|
426
|
+
**Critical difference:** The AI doesn't need to "think through" all possible change paths. It translates requirements to rules, and the engine provides correctness guarantee through automatic dependency analysis and chaining.
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
162
430
|
## 🔄 Development Workflow
|
|
163
431
|
|
|
164
432
|
**Source Repository:** https://github.com/ApiLogicServer/ApiLogicServer-src
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ApiLogicServer
|
|
3
|
-
Version: 15.2.
|
|
3
|
+
Version: 15.2.10
|
|
4
4
|
Author-email: Val Huber <apilogicserver@gmail.com>
|
|
5
5
|
License-Expression: BSD-3-Clause
|
|
6
6
|
Project-URL: Homepage, https://www.genai-logic.com
|
|
@@ -104,10 +104,10 @@ source venv/bin/activate # windows: venv\Scripts\activate
|
|
|
104
104
|
python -m pip install ApiLogicServer
|
|
105
105
|
|
|
106
106
|
# Start the Manager (opens readme with instructions)
|
|
107
|
-
|
|
107
|
+
genai-logic start
|
|
108
108
|
|
|
109
109
|
# Create project from your database (or use sample)
|
|
110
|
-
|
|
110
|
+
genai-logic create --project_name=my_app --db_url=
|
|
111
111
|
|
|
112
112
|
# Run it
|
|
113
113
|
cd my_app
|
|
@@ -116,11 +116,14 @@ python api_logic_server_run.py
|
|
|
116
116
|
|
|
117
117
|
**What you get in 5 seconds:**
|
|
118
118
|
- 🚀 **JSON:API** - Endpoints for every table with filtering, pagination, related data
|
|
119
|
-
- 📱 **Admin App** - Multi-page React app with automatic joins
|
|
119
|
+
- 📱 **Instant Admin App UI** - Multi-page React app with automatic joins (runs immediately)
|
|
120
|
+
- 🎨 **Custom Apps via API** - Use the API with your favorite vibe tools (Cursor, Bolt, Lovable, etc.) OR leverage GenAI-Logic training for Copilot to build custom UIs ([see this article](https://medium.com/@valjhuber/enterprise-vibe-automation-b40c8f750a1d))
|
|
120
121
|
- 🧠 **Logic Engine** - Spreadsheet-like rules (40X more concise than code)
|
|
121
122
|
- 🔐 **Security** - Row-level authorization, JWT authentication
|
|
122
123
|
- 🐳 **Docker-ready** - Pre-configured containers for deployment
|
|
123
124
|
|
|
125
|
+
**Mix and match:** Use the instant Admin App for backoffice tasks AND build custom UIs with vibe tools for advanced features like cards and maps - all powered by the same logic-enabled API.
|
|
126
|
+
|
|
124
127
|
**[📖 8-minute video demo](https://www.youtube.com/watch?v=Z4_NJIm5rFs&t=323s)** | **[📚 Full Documentation](https://apilogicserver.github.io/Docs/)** | **[🏠 Home](https://www.genai-logic.com)**
|
|
125
128
|
|
|
126
129
|
---
|
|
@@ -137,8 +140,8 @@ python api_logic_server_run.py
|
|
|
137
140
|
| Traditional Approach | API Logic Server |
|
|
138
141
|
|---------------------|------------------|
|
|
139
142
|
| Weeks to create API endpoints | **5 seconds** (automated) |
|
|
140
|
-
| 200+ lines of update logic code | **5 rules** (40X reduction) |
|
|
141
|
-
| Manual screen painting | **Automated** from data model |
|
|
143
|
+
| 200+ lines of update logic code | **5 rules** (40X reduction - to see an A/B Comparision, [click here](https://github.com/ApiLogicServer/basic_demo/blob/main/logic/procedural/declarative-vs-procedural-comparison.md) |
|
|
144
|
+
| Manual screen painting | **Automated** from data model, plus vibe-enabled custom UIs |
|
|
142
145
|
| Hard to integrate systems | **MCP-enabled** APIs |
|
|
143
146
|
| Opaque procedural code | **Declarative** living documentation |
|
|
144
147
|
|
|
@@ -240,22 +243,28 @@ A: Join our **[Discord community](https://discord.gg/fNRTTVFT)** for real-time h
|
|
|
240
243
|
|
|
241
244
|
```
|
|
242
245
|
my_app/
|
|
243
|
-
├── api/ # JSON:API endpoints
|
|
246
|
+
├── api/ # JSON:API endpoints (for Admin App AND custom UIs)
|
|
244
247
|
│ ├── expose_api_models.py
|
|
245
248
|
│ └── customize_api.py # Add custom endpoints
|
|
246
|
-
├── ui/admin/ # Admin App
|
|
249
|
+
├── ui/admin/ # Instant Admin App (ready to run)
|
|
247
250
|
│ └── admin.yaml # Declare UI behavior
|
|
248
|
-
├── logic/ # Business Logic
|
|
251
|
+
├── logic/ # Business Logic (enforced on ALL API calls)
|
|
249
252
|
│ └── declare_logic.py # Spreadsheet-like rules
|
|
250
253
|
├── security/ # Authentication & Authorization
|
|
251
254
|
│ └── declare_security.py
|
|
252
255
|
├── database/ # SQLAlchemy models
|
|
253
256
|
│ └── models.py
|
|
254
257
|
├── tests/ # BDD tests (Behave)
|
|
258
|
+
├── docs/
|
|
259
|
+
│ └── training/ # GenAI-Logic training for Copilot
|
|
255
260
|
└── devops/
|
|
256
261
|
└── docker/ # Deployment configs
|
|
257
262
|
```
|
|
258
263
|
|
|
264
|
+
**Two UI approaches (use both!):**
|
|
265
|
+
1. **Instant Admin App** - Runs immediately for backoffice/internal users
|
|
266
|
+
2. **Custom UIs** - Build with vibe tools (Cursor, Bolt, etc.) OR use GenAI-Logic Copilot training to create React/Vue/Angular apps that consume the API
|
|
267
|
+
|
|
259
268
|
---
|
|
260
269
|
|
|
261
270
|
## 🚀 Key Features
|
|
@@ -310,7 +319,7 @@ GET /api/Customer?filter[Balance][$gt]=1000&sort=-Balance&page[size]=10
|
|
|
310
319
|
|
|
311
320
|
#### Create from Natural Language
|
|
312
321
|
```bash
|
|
313
|
-
|
|
322
|
+
genai-logic genai --using=prompt.txt
|
|
314
323
|
```
|
|
315
324
|
|
|
316
325
|
**Example prompt:**
|
|
@@ -324,24 +333,24 @@ Constraint: customer balance cannot exceed credit limit.
|
|
|
324
333
|
```
|
|
325
334
|
|
|
326
335
|
**Result:** Working microservice with logic in 10 seconds!
|
|
327
|
-
|
|
328
336
|
#### AI-Assisted Development
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
337
|
+
|
|
338
|
+
Every created project includes **AI tutoring** to help you get oriented and productive quickly:
|
|
339
|
+
|
|
340
|
+
- 🤖 **Copilot instructions** (`.copilot-instructions.md`) - When you open a project, Copilot presents a friendly welcome message explaining what's already built and what you can do next. Ask Copilot to "read instructions" anytime for guidance.
|
|
341
|
+
- 📚 **Training materials** (`docs/training/`) - Comprehensive guides for all features
|
|
332
342
|
- 🔍 **Logic from natural language** (translate English → rules)
|
|
333
343
|
|
|
334
344
|
```python
|
|
335
345
|
# Paste into Copilot: "Create logic for check credit"
|
|
336
346
|
# Copilot generates the 5 rules above!
|
|
337
347
|
```
|
|
338
|
-
|
|
339
348
|
### 4️⃣ Living Documentation
|
|
340
349
|
|
|
341
350
|
**Automated test generation** from your rules:
|
|
342
351
|
```bash
|
|
343
352
|
# Generate Behave tests from declared logic
|
|
344
|
-
|
|
353
|
+
genai-logic add-tests
|
|
345
354
|
|
|
346
355
|
# Run tests
|
|
347
356
|
behave
|