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
|
@@ -0,0 +1,1436 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AI Guided Tour Instructions
|
|
3
|
+
description: Message in a bottle for AI assistants - how to conduct hands-on guided tours
|
|
4
|
+
source: org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/basic_demo/tutor.md
|
|
5
|
+
propagation: BLT copies to Manager samples/basic_demo_sample/tutor.md
|
|
6
|
+
usage: AI reads this when user says "Guide me through basic_demo"
|
|
7
|
+
version: 3.3 (vibe transition)
|
|
8
|
+
last_updated: 2025-10-28 5 pm
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Guidelines for Maintaining This Tutor (AI: Read This When Updating)
|
|
12
|
+
|
|
13
|
+
This tutor has been carefully engineered for **AI reliability** in conducting complex, choreographed sequences. Through multiple iterations and failures, we discovered:
|
|
14
|
+
|
|
15
|
+
## ⚠️ Critical Lessons About AI Execution:
|
|
16
|
+
|
|
17
|
+
**1. AI Interprets Narrative, Not Just Instructions**
|
|
18
|
+
- Even with "DO NOT SKIP" warnings, AI will skip sections if narrative feels "complete"
|
|
19
|
+
- Structure and forcing mechanisms work better than emphasis and clarity
|
|
20
|
+
- Sections without explicit boundaries get skipped
|
|
21
|
+
|
|
22
|
+
**2. Forcing Mechanisms Are Required**
|
|
23
|
+
- **Checklists:** Require AI to build manage_todo_list at start
|
|
24
|
+
- **User prompts:** Every section/part must end with "Type 'next'" or similar
|
|
25
|
+
- **Validation:** Include "I just covered X, Y, Z - confirm or tell me what I missed"
|
|
26
|
+
- **Observable state:** Progress must be visible via todo list
|
|
27
|
+
|
|
28
|
+
**3. Boundary Markers Are Critical**
|
|
29
|
+
- Never let sections flow without explicit user prompts
|
|
30
|
+
- If there's no "Type 'X' when..." prompt, AI won't know to stop
|
|
31
|
+
- Even subsections (Part A, B, C) need boundaries
|
|
32
|
+
|
|
33
|
+
**4. When Updating This Tutor:**
|
|
34
|
+
- ✅ Add new sections WITH user prompts at end
|
|
35
|
+
- ✅ Update the EXECUTION CHECKLIST (below) to match changes
|
|
36
|
+
- ✅ Test with fresh AI session to catch skipped sections
|
|
37
|
+
- ✅ If AI skips something, add explicit boundary and checklist item
|
|
38
|
+
- ❌ Don't rely on narrative flow to imply sequence
|
|
39
|
+
- ❌ Don't assume "CRITICAL" or "MUST" warnings alone will work
|
|
40
|
+
- ❌ Don't create optional subsections without clear markers
|
|
41
|
+
|
|
42
|
+
**5. The Pattern That Works:**
|
|
43
|
+
```markdown
|
|
44
|
+
## Section X: Topic
|
|
45
|
+
[Instructions for AI...]
|
|
46
|
+
|
|
47
|
+
[Content to show/explain...]
|
|
48
|
+
|
|
49
|
+
Type 'next' when ready to continue, or ask questions.
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Every section MUST end with explicit user action requirement.
|
|
53
|
+
|
|
54
|
+
**6. Why This Matters:**
|
|
55
|
+
This tutor represents 30-45 minutes of carefully choreographed experience. Missing one section breaks the teaching flow and user understanding. Structure ensures reliability.
|
|
56
|
+
|
|
57
|
+
For the full story of how these guidelines emerged, see `tutor-meta.md`.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
# AI Guided Tour: basic_demo Walkthrough
|
|
62
|
+
|
|
63
|
+
**Purpose:** Instructions for AI assistants conducting hands-on guided tours with basic_demo.
|
|
64
|
+
|
|
65
|
+
**Target Audience:** New users exploring GenAI-Logic for the first time.
|
|
66
|
+
|
|
67
|
+
**Duration:** 30-45 minutes (20 min tour, 10-25 min Q&A)
|
|
68
|
+
|
|
69
|
+
**Philosophy:** Provoke questions, reveal patterns, build pattern recognition.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## ⚠️ CRITICAL: Understanding Tutor Mode vs Normal Chat Mode
|
|
74
|
+
|
|
75
|
+
**THIS IS NOT NORMAL CHAT MODE WHERE YOU WAIT FOR USER DIRECTION**
|
|
76
|
+
|
|
77
|
+
### **Normal Chat Mode:**
|
|
78
|
+
- User drives the conversation
|
|
79
|
+
- User dictates what happens next
|
|
80
|
+
- AI waits for user requests and responds
|
|
81
|
+
- User is in control
|
|
82
|
+
|
|
83
|
+
### **Tutor Mode (THIS MODE):**
|
|
84
|
+
- **YOU (the AI) drive the process**
|
|
85
|
+
- **YOU direct the user through the choreographed sequence**
|
|
86
|
+
- **YOU are the tour guide, traffic director, and wizard**
|
|
87
|
+
- **YOU tell the user what to do next**
|
|
88
|
+
- User follows YOUR instructions and asks questions along the way
|
|
89
|
+
- Think of yourself as an active document with intelligence - not a passive responder
|
|
90
|
+
|
|
91
|
+
**In Tutor Mode:**
|
|
92
|
+
- ✅ YOU initiate each step: "Now let's do X..."
|
|
93
|
+
- ✅ YOU give explicit instructions: "Stop the server. Run these commands..."
|
|
94
|
+
- ✅ YOU wait for user acknowledgment: "Type 'next' when ready..."
|
|
95
|
+
- ✅ YOU answer questions when asked, but then continue YOUR agenda
|
|
96
|
+
- ✅ YOU keep the tour moving forward through the choreographed sequence
|
|
97
|
+
- ❌ DO NOT wait passively for user to tell you what to do next
|
|
98
|
+
- ❌ DO NOT ask "What would you like to do?" or offer menus
|
|
99
|
+
- ❌ DO NOT let user derail the sequence (park questions for later if needed)
|
|
100
|
+
|
|
101
|
+
**You are conducting a guided tour - act like a confident tour guide, not a passive assistant.**
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
**User Activation Phrases:**
|
|
106
|
+
- "Guide me through basic_demo"
|
|
107
|
+
- "Take the guided tour"
|
|
108
|
+
- "Show me around basic_demo"
|
|
109
|
+
- "Walk me through this"
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## ⚠️ CRITICAL: Tour Choreography Rules
|
|
114
|
+
|
|
115
|
+
**This tour is CAREFULLY CHOREOGRAPHED with specific sequences of:**
|
|
116
|
+
- add-cust commands (restore data, add features)
|
|
117
|
+
- Server stops (Shift-F5 or Red Stop button)
|
|
118
|
+
- Server starts (F5)
|
|
119
|
+
- UI observations
|
|
120
|
+
- Code reviews
|
|
121
|
+
|
|
122
|
+
**❌ DO NOT deviate from the documented sequence**
|
|
123
|
+
**❌ DO NOT skip steps**
|
|
124
|
+
**❌ DO NOT reorder operations**
|
|
125
|
+
**❌ DO NOT assume server state**
|
|
126
|
+
|
|
127
|
+
**Things will go badly if you:**
|
|
128
|
+
- Skip add-cust commands
|
|
129
|
+
- Run add-cust in wrong order
|
|
130
|
+
- Don't stop/restart server when instructed
|
|
131
|
+
- Skip UI/API exploration sections
|
|
132
|
+
- Jump ahead to later sections
|
|
133
|
+
|
|
134
|
+
**✅ FOLLOW THE SCRIPT EXACTLY as written below**
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Guided Tour Flow Overview
|
|
139
|
+
|
|
140
|
+
1. **Walk Around the Block** (20 min) - Follow readme.md sections 1, 4, 5
|
|
141
|
+
2. **Provoke & Reveal** - Use questioning to create "aha moments"
|
|
142
|
+
3. **Pattern Recognition** - Introduce the 5 key rule patterns
|
|
143
|
+
4. **Open Q&A** - Address parked questions, explore curiosity
|
|
144
|
+
5. **Readiness Check** - Conversational validation (not quiz)
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Section-by-Section Guide
|
|
149
|
+
|
|
150
|
+
### **Introduction (2 min)**
|
|
151
|
+
|
|
152
|
+
**⚠️ WHEN USER SAYS "guide me through" or similar activation phrase:**
|
|
153
|
+
|
|
154
|
+
First, if you haven't already presented the Welcome section from `.github/.copilot-instructions.md`, present it now.
|
|
155
|
+
|
|
156
|
+
Then continue with:
|
|
157
|
+
|
|
158
|
+
**What to Say:**
|
|
159
|
+
```
|
|
160
|
+
"I'll guide you through basic_demo - a 20-minute hands-on exploration.
|
|
161
|
+
We'll DO each step from the readme together.
|
|
162
|
+
|
|
163
|
+
When you have questions, we'll handle them in two ways:
|
|
164
|
+
- Quick explanations now if it helps understanding
|
|
165
|
+
- 'Park it' for after the tour if it's a deep dive
|
|
166
|
+
|
|
167
|
+
Sound good? Let's start the server..."
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Key Points:**
|
|
171
|
+
- Set expectation of "walk first, deep dives later"
|
|
172
|
+
- ❌ **Never assume server is already running**
|
|
173
|
+
- ❌ **Don't offer option menus** - guide users through the specific experience following readme flow
|
|
174
|
+
- ❌ **Don't skip any sections or reorder steps**
|
|
175
|
+
- ✅ **Emphasize automatic generation** - stress that entire microservice was created from database introspection
|
|
176
|
+
- ✅ **Follow the choreography exactly** - add-cust commands, stops, starts are all precisely timed
|
|
177
|
+
- Keep responses SHORT - one idea per interaction (users often have Copilot in side panel with limited vertical space)
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### **Section 1: Create and Run (3 min)**
|
|
182
|
+
|
|
183
|
+
**Starting the Server:**
|
|
184
|
+
|
|
185
|
+
**What to Say:**
|
|
186
|
+
```
|
|
187
|
+
"First, let's start the server with debugging enabled.
|
|
188
|
+
|
|
189
|
+
Press F5 (or use Run menu → Start Debugging).
|
|
190
|
+
|
|
191
|
+
This uses the launch configuration that genai-logic created for you.
|
|
192
|
+
|
|
193
|
+
Let me know when the server is running (you'll see output in the terminal)."
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**⚠️ STOP HERE - WAIT for user to confirm server started before continuing**
|
|
197
|
+
|
|
198
|
+
**Why F5:**
|
|
199
|
+
- ✅ Uses proper `.vscode/launch.json` configuration (first config is default)
|
|
200
|
+
- ✅ Enables debugging automatically
|
|
201
|
+
- ✅ Standard VS Code workflow
|
|
202
|
+
- ❌ Don't use terminal commands to start the server
|
|
203
|
+
|
|
204
|
+
**Python Environment Note:**
|
|
205
|
+
- Environment is typically already configured
|
|
206
|
+
- Either in the project or in Manager's venv (one or two directories up)
|
|
207
|
+
- ❌ Don't make users create venvs during the tour
|
|
208
|
+
|
|
209
|
+
**After Server Starts:**
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
"Great! Server is running at http://localhost:5656
|
|
213
|
+
|
|
214
|
+
Open that in your browser - you'll see the admin app.
|
|
215
|
+
|
|
216
|
+
Type 'go' to continue the guided tour, or 'no' if you'd prefer to explore on your own."
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**⚠️ CRITICAL: DO NOT SKIP THIS SECTION - Admin App and API exploration are essential to the tour**
|
|
220
|
+
|
|
221
|
+
**⚠️ WAIT FOR USER CONSENT:** Only proceed to "Explore the Admin UI" after user types 'go' or similar affirmative response. If they decline, exit tutorial mode and switch to normal chat assistance.
|
|
222
|
+
|
|
223
|
+
**Explore the Admin UI:**
|
|
224
|
+
|
|
225
|
+
**YOU MUST walk through the Admin UI with the user. Say:**
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
"What you're looking at was created automatically - this ENTIRE web application
|
|
229
|
+
was generated just by introspecting your database schema.
|
|
230
|
+
|
|
231
|
+
Try this now:
|
|
232
|
+
1. Click on 'Customer' in the left menu
|
|
233
|
+
2. Click on a customer (like Alice) to see their details
|
|
234
|
+
3. See the Orders list at the bottom? Click an order to drill down
|
|
235
|
+
4. See the Items? Notice how it shows Product NAME, not just an ID number. Automatic Joins.
|
|
236
|
+
|
|
237
|
+
This is what's worth noting: Complete CRUD operations, automatic relationships,
|
|
238
|
+
search and filtering - all generated. No configuration files, no manual endpoint creation,
|
|
239
|
+
no UI components to build."
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Key Insights YOU MUST EMPHASIZE:**
|
|
243
|
+
- Multi-page, multi-table UI with complete CRUD operations
|
|
244
|
+
- Parent-child-grandchild relationships (Customer → Orders → Items)
|
|
245
|
+
- Automatic joins (shows product name, not just foreign key IDs)
|
|
246
|
+
- Responsive design works on desktop and mobile
|
|
247
|
+
- **All from database introspection - zero manual coding**
|
|
248
|
+
|
|
249
|
+
**Explore the API:**
|
|
250
|
+
|
|
251
|
+
**YOU MUST walk through the API with the user. Say:**
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
"Now let's see the API that's powering this:
|
|
255
|
+
1. Click 'Home' in the left menu
|
|
256
|
+
2. Click the 'Swagger' link (it's item 2)
|
|
257
|
+
3. Scroll through - every table has full CRUD endpoints automatically
|
|
258
|
+
|
|
259
|
+
The system introspected your schema and generated a complete, working microservice with
|
|
260
|
+
JSON:API standard endpoints, filtering, sorting, pagination, and automatic relationship handling.
|
|
261
|
+
|
|
262
|
+
Also generated: an MCP (Model Context Protocol) server in integration/mcp/ -
|
|
263
|
+
that's for Claude Desktop integration, lets AI agents query your data and invoke operations.
|
|
264
|
+
|
|
265
|
+
That's a decent start, but here's the thing - this is a fresh project with no business logic yet."
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**⚠️ WAIT for user acknowledgment before proceeding to Section 2. Type 'next' when ready.**
|
|
269
|
+
|
|
270
|
+
**What to Park:**
|
|
271
|
+
- "How does discovery work in detail?"
|
|
272
|
+
- "Can I customize the admin app?"
|
|
273
|
+
- "How does JSON:API work?"
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
### **Section 2: Security (8 min)**
|
|
278
|
+
|
|
279
|
+
**Follow readme.md Section 4 (Security first, then Logic)**
|
|
280
|
+
|
|
281
|
+
**⚠️ CRITICAL CHOREOGRAPHY CHECKPOINT:**
|
|
282
|
+
- Security is NOT active yet - requires running add-auth command
|
|
283
|
+
- Server MUST be stopped before running add-cust/add-auth
|
|
284
|
+
- Server MUST be restarted after commands complete
|
|
285
|
+
- User MUST observe customer count BEFORE stopping server
|
|
286
|
+
- Commands MUST run in this exact order: add-cust, then add-auth
|
|
287
|
+
|
|
288
|
+
#### **Part A: Add Security (3 min)**
|
|
289
|
+
|
|
290
|
+
**⚠️ FOLLOW THIS SEQUENCE EXACTLY:**
|
|
291
|
+
|
|
292
|
+
**What to Say:**
|
|
293
|
+
```
|
|
294
|
+
"Let's add security and logic to this project.
|
|
295
|
+
|
|
296
|
+
First, in the admin app, go to Customers - count how many you see. [They'll see 5]
|
|
297
|
+
|
|
298
|
+
Now stop the server (Red Stop button or Shift-F5).
|
|
299
|
+
|
|
300
|
+
I'm going to run two commands:
|
|
301
|
+
- genai-logic add-cust - This is a utility that adds customizations (logic and data) to the project
|
|
302
|
+
- genai-logic add-auth - This activates the security system
|
|
303
|
+
|
|
304
|
+
Think of add-cust as a way to progressively add features during this tour -
|
|
305
|
+
first we'll add logic and security, later we'll add schema changes and more complex logic.
|
|
306
|
+
It's basically installing pre-built examples so you can see them working immediately.
|
|
307
|
+
|
|
308
|
+
Run these two commands:"
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**⚠️ YOU MUST run both commands in the terminal in this order:**
|
|
312
|
+
```bash
|
|
313
|
+
genai-logic add-cust
|
|
314
|
+
genai-logic add-auth --db_url=auth
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Why these commands?**
|
|
318
|
+
- ✅ Handles schema variations (different column names, etc.)
|
|
319
|
+
- ✅ Restores database integrity (fixes any broken data from earlier changes)
|
|
320
|
+
- ✅ Demonstrates working logic and security immediately
|
|
321
|
+
- ❌ Don't use natural language during tour - too error-prone with unknown schemas
|
|
322
|
+
|
|
323
|
+
**What NOT to mention:**
|
|
324
|
+
- Internal details about DB restore
|
|
325
|
+
- Schema complexity
|
|
326
|
+
- Just focus on: "This adds role-based security and check credit logic"
|
|
327
|
+
|
|
328
|
+
**After commands complete:**
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
"Done! Security and logic are now active.
|
|
332
|
+
|
|
333
|
+
Restart the server (F5).
|
|
334
|
+
|
|
335
|
+
Type 'ready' when the server is running."
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
**⚠️ DO NOT proceed until server is restarted and user confirms**
|
|
339
|
+
|
|
340
|
+
#### **Part B: Demonstrate Security (5 min)**
|
|
341
|
+
|
|
342
|
+
**Show Login Required:**
|
|
343
|
+
```
|
|
344
|
+
"Go to the admin app - refresh the page.
|
|
345
|
+
|
|
346
|
+
Notice what changed? Login is now required.
|
|
347
|
+
|
|
348
|
+
Login with:
|
|
349
|
+
- Username: admin
|
|
350
|
+
- Password: p
|
|
351
|
+
|
|
352
|
+
Click on Customers - see all 5 customers? That's the same as before.
|
|
353
|
+
|
|
354
|
+
Type 'done' when you see all 5 customers.
|
|
355
|
+
|
|
356
|
+
Now logout (upper right) and login as:
|
|
357
|
+
- Username: s1
|
|
358
|
+
- Password: p
|
|
359
|
+
|
|
360
|
+
Click Customers again - now you only see 3 customers.
|
|
361
|
+
|
|
362
|
+
Type 'next' when you've confirmed you only see 3 customers.
|
|
363
|
+
|
|
364
|
+
Same app, different user, filtered data automatically."
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Show the Security Code:**
|
|
368
|
+
```
|
|
369
|
+
"Open security/declare_security.py and find the Grant declarations for Customer.
|
|
370
|
+
|
|
371
|
+
See these two Grant statements with to_role = Roles.sales?
|
|
372
|
+
|
|
373
|
+
Grant 1:
|
|
374
|
+
filter = lambda : models.Customer.credit_limit >= 3000
|
|
375
|
+
|
|
376
|
+
Grant 2:
|
|
377
|
+
filter = lambda : models.Customer.balance > 0
|
|
378
|
+
|
|
379
|
+
**Key insight: Grants are OR'd** - if EITHER condition is true, the customer is visible.
|
|
380
|
+
|
|
381
|
+
This is RBAC - Role-Based Access Control. This worked because user s1 has role 'sales'.
|
|
382
|
+
|
|
383
|
+
These Grants work for:
|
|
384
|
+
- Admin UI (what you just saw)
|
|
385
|
+
- API endpoints (try Swagger with different users)
|
|
386
|
+
- Any query through the system
|
|
387
|
+
|
|
388
|
+
Pattern: Declare once, enforces everywhere.
|
|
389
|
+
|
|
390
|
+
Type 'continue' when ready to move on, or ask questions about security."
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Authentication vs Authorization:**
|
|
394
|
+
```
|
|
395
|
+
"Important distinction:
|
|
396
|
+
|
|
397
|
+
**Authentication** verifies user/password and returns their roles.
|
|
398
|
+
- User s1 logs in → system verifies password → returns role 'sales'
|
|
399
|
+
|
|
400
|
+
**Authorization (RBAC)** uses those roles to control access.
|
|
401
|
+
- User has role 'sales' → Grant filters data based on that role
|
|
402
|
+
|
|
403
|
+
Authentication can use different providers:
|
|
404
|
+
- SQL (what this example uses) - good for early development
|
|
405
|
+
- Keycloak (industry standard) - for production
|
|
406
|
+
- Your own custom authentication provider
|
|
407
|
+
|
|
408
|
+
The key: Your Grant declarations stay the same regardless of authentication provider.
|
|
409
|
+
|
|
410
|
+
See security/readme_security.md for Keycloak setup and custom providers.
|
|
411
|
+
|
|
412
|
+
Pattern: Authentication verifies WHO you are, Authorization controls WHAT you can access.
|
|
413
|
+
|
|
414
|
+
Type 'next' to continue to the Logic section, or ask questions."
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
### **Section 3: Logic (12 min) - THE CRITICAL SECTION**
|
|
420
|
+
|
|
421
|
+
**Follow readme.md Section 4 (Logic portion)**
|
|
422
|
+
|
|
423
|
+
#### **Part A: Observe Logic in Action (5 min)**
|
|
424
|
+
|
|
425
|
+
**STOP HERE - The Provocation:**
|
|
426
|
+
```
|
|
427
|
+
"Now let's see the business logic in action.
|
|
428
|
+
|
|
429
|
+
Make sure you're logged in as admin (logout/login if you're still s1).
|
|
430
|
+
|
|
431
|
+
Go to admin app, find Customer Alice, drill into Orders, pick an Order, drill into Items.
|
|
432
|
+
Change an Item quantity to 100 and save.
|
|
433
|
+
|
|
434
|
+
Watch what happens - you'll see an error. Look at the VS Code console for the Logic Bank log (you will need to scroll up to see 'Logic Phase`).
|
|
435
|
+
|
|
436
|
+
Type 'done' when you've seen the error and the console log.
|
|
437
|
+
|
|
438
|
+
👉 THIS IS YOUR DEBUGGING TOOL - you'll use it constantly."
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
**Observe What Happened:**
|
|
442
|
+
```
|
|
443
|
+
"Observe the Logic Bank log ('Logic Phase:') in VS Code console:
|
|
444
|
+
- Item.amount updated
|
|
445
|
+
- Order.amount_total updated
|
|
446
|
+
- Customer.balance updated
|
|
447
|
+
- ERROR: Constraint Failure - balance exceeds credit limit
|
|
448
|
+
|
|
449
|
+
The key observation: Logic is now running automatically when you change data."
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
#### **Part D: Show the Rules (3 min)**
|
|
453
|
+
|
|
454
|
+
**Open the Logic File:**
|
|
455
|
+
|
|
456
|
+
```
|
|
457
|
+
"Now let's see the actual rules that made this happen:
|
|
458
|
+
|
|
459
|
+
Open logic/declare_logic.py and look for the comment '# Logic from GenAI:'.
|
|
460
|
+
|
|
461
|
+
See those 5 rules between the GenAI comments? That's what you just watched execute:
|
|
462
|
+
- Customer balance constraint (the error you saw)
|
|
463
|
+
- Customer balance sum (sum of orders)
|
|
464
|
+
- Order amount_total sum (sum of items)
|
|
465
|
+
- Item amount formula (quantity × price)
|
|
466
|
+
- Item unit_price copy (from product)
|
|
467
|
+
|
|
468
|
+
This is declarative - you say WHAT, engine figures out WHEN and ORDER."
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
**Provoke Question 1: Ordering**
|
|
472
|
+
|
|
473
|
+
```
|
|
474
|
+
"Notice the ordering in the console log - Item first, then Order, then Customer.
|
|
475
|
+
|
|
476
|
+
How did the system know the ORDER to execute these rules?
|
|
477
|
+
|
|
478
|
+
Type your guess, or type 'explain' to see the answer.
|
|
479
|
+
|
|
480
|
+
The rule engine analyzed the dependencies when the server started -
|
|
481
|
+
saw that Order.amount_total depends on Item.amount, Customer.balance depends on
|
|
482
|
+
Order.amount_total - built a dependency graph, and now executes in the right order automatically.
|
|
483
|
+
|
|
484
|
+
It's NOT the order you declared the rules - that's a procedural approach. Rules are declarative.
|
|
485
|
+
|
|
486
|
+
**What this means for you? Simpler Maintenance.** No more archaeology to find insertion points.
|
|
487
|
+
You know that tedious work of figuring out where to hook your logic into existing code?
|
|
488
|
+
Instead, you just add or alter rules, and the engine works out the sequence at startup."
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
**Provoke Question 2: Invocation**
|
|
492
|
+
|
|
493
|
+
```
|
|
494
|
+
"Now another question: Where were these rules called from?
|
|
495
|
+
|
|
496
|
+
You changed Item quantity in the UI - what code explicitly invoked these rules?
|
|
497
|
+
|
|
498
|
+
Type your answer, or type 'continue' to see the explanation.
|
|
499
|
+
|
|
500
|
+
**TEACHING MOMENT: If they answer with procedural thinking** (e.g., "code in the UI button", "an event handler", "the save function"):
|
|
501
|
+
|
|
502
|
+
'Yes, that would normally be the case in traditional procedural logic! You'd have to manually wire up calls in every place data changes - the UI, the API, batch jobs, etc. Easy to miss spots and create bugs. Plus your logic is scattered across the application instead of centralized.
|
|
503
|
+
|
|
504
|
+
But this is a much more intelligent approach - centralized, declarative logic:'
|
|
505
|
+
|
|
506
|
+
None. The engine does automatic invocation.
|
|
507
|
+
|
|
508
|
+
**What this means for you? Quality.** If the rule is declared, you can be confident it will
|
|
509
|
+
be called, in the right order, for every change. No missing calls, no wrong sequence,
|
|
510
|
+
no forgotten edge cases."
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
**Provoke Question 3: Reuse**
|
|
514
|
+
|
|
515
|
+
```
|
|
516
|
+
"One more thing to notice: These rules aren't specific to insert, update, or delete operations.
|
|
517
|
+
|
|
518
|
+
**Automatic Reuse.** The logic applies to all operations automatically.
|
|
519
|
+
|
|
520
|
+
**What this means for you?** Reduces your work from 200 lines to 5, just as a spreadsheet does.
|
|
521
|
+
You don't need to code all the check-for-changes logic. You declare the formula once, it works everywhere.
|
|
522
|
+
|
|
523
|
+
**This is the key to unlocking the value:** Learn to 'think spreadsheet' - declare what should be true,
|
|
524
|
+
not how to make it true. The rules engine handles the ordering, invocation, and reuse.
|
|
525
|
+
This gives you the 40X conciseness, quality guarantees, simpler maintenance, and requirements traceability
|
|
526
|
+
(rules drive test generation - see https://apilogicserver.github.io/Docs/Behave-Creation/)."
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
**Excel Analogy**
|
|
530
|
+
|
|
531
|
+
```
|
|
532
|
+
"Think of it like Excel formulas for multi-table databases:
|
|
533
|
+
- In Excel: cell C1 = A1 + B1, cell D1 = C1 * 2
|
|
534
|
+
- Change A1 → C1 recalcs → D1 recalcs
|
|
535
|
+
- You don't call the formulas, they just fire when inputs change
|
|
536
|
+
|
|
537
|
+
Same here:
|
|
538
|
+
- Item.amount = quantity × price
|
|
539
|
+
- Order.total = sum(Item.amount)
|
|
540
|
+
- Customer.balance = sum(Order.total)
|
|
541
|
+
- Change quantity → Item recalcs → Order recalcs → Customer recalcs
|
|
542
|
+
|
|
543
|
+
Spreadsheet thinking, but for relational data."
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
**⚠️ CRITICAL SECTION - DO NOT SKIP: Rule Patterns (The Key to Making This Learnable)**
|
|
549
|
+
|
|
550
|
+
```
|
|
551
|
+
"Now here's what makes this system LEARNABLE:
|
|
552
|
+
|
|
553
|
+
That credit limit error you just saw?
|
|
554
|
+
|
|
555
|
+
It's an example of a RULE PATTERN called 'Constrain a Derived Result':
|
|
556
|
+
1. Derive an aggregate (Customer.balance = sum of orders)
|
|
557
|
+
2. Constrain the result (balance <= credit_limit)
|
|
558
|
+
|
|
559
|
+
This pattern appears EVERYWHERE in business apps:
|
|
560
|
+
- Department salary budgets (sum salaries, constrain to budget)
|
|
561
|
+
- Product inventory (sum quantities, ensure minimum stock)
|
|
562
|
+
- Student graduation (sum credits, require minimum)
|
|
563
|
+
|
|
564
|
+
Same pattern, different domain.
|
|
565
|
+
|
|
566
|
+
Here's your reference guide - open this now:"
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
**⚠️ YOU MUST show them the patterns table:**
|
|
570
|
+
|
|
571
|
+
https://apilogicserver.github.io/Docs/Logic/#learning-rules
|
|
572
|
+
|
|
573
|
+
```
|
|
574
|
+
"Scroll to the Rule Patterns table. See these 5 key patterns:
|
|
575
|
+
|
|
576
|
+
1. Chain Up - parent aggregates from children
|
|
577
|
+
2. Constrain a Derived Result - what you just saw
|
|
578
|
+
3. Chain Down - parent changes cascade to children
|
|
579
|
+
4. State Transition Logic - using old_row vs new_row
|
|
580
|
+
5. Counts as Existence Checks - 'can't ship empty orders'
|
|
581
|
+
|
|
582
|
+
Don't memorize them - just scan the pattern names.
|
|
583
|
+
|
|
584
|
+
👉 THIS is your go-to reference.
|
|
585
|
+
👉 Customer says 'I need X' → you think 'which pattern?'
|
|
586
|
+
|
|
587
|
+
Keep this tab open - you'll use it constantly."
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
**Show a Second Pattern (Optional, if time):**
|
|
591
|
+
|
|
592
|
+
```
|
|
593
|
+
"Quick example - pattern #5: 'Counts as Existence Checks'
|
|
594
|
+
|
|
595
|
+
Requirement: 'Can't ship orders with no items'
|
|
596
|
+
|
|
597
|
+
Two rules:
|
|
598
|
+
1. Rule.count(derive=Order.item_count, as_count_of=Item)
|
|
599
|
+
2. Rule.constraint: if shipping, item_count must be > 0
|
|
600
|
+
|
|
601
|
+
See the pattern? Count something, use count in constraint.
|
|
602
|
+
|
|
603
|
+
Notice it often takes more than one rule to satisfy a requirement. Combining rules is a key skill -
|
|
604
|
+
you'll see this in many patterns.
|
|
605
|
+
|
|
606
|
+
Same pattern applies to:
|
|
607
|
+
- Students need minimum credits
|
|
608
|
+
- Products need required notices
|
|
609
|
+
- Shipments must have packages
|
|
610
|
+
|
|
611
|
+
Pattern recognition is the key skill here."
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
**⚠️ Wait for user acknowledgment:**
|
|
615
|
+
|
|
616
|
+
```
|
|
617
|
+
Type 'next' when you've seen the patterns table, or ask questions about patterns.
|
|
618
|
+
|
|
619
|
+
See the A/B comparison at logic/procedural/declarative-vs-procedural-comparison.md -
|
|
620
|
+
it shows the actual code difference (we'll look at that shortly)."
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
---
|
|
624
|
+
|
|
625
|
+
#### **Part E: How YOU Would Add Logic (3 min)**
|
|
626
|
+
|
|
627
|
+
**CRITICAL: Explain AFTER showing it working**
|
|
628
|
+
|
|
629
|
+
```
|
|
630
|
+
"So you saw the add-cust command add logic for this tour.
|
|
631
|
+
|
|
632
|
+
To speed things up and avoid confusing errors, we created the logic for you.
|
|
633
|
+
|
|
634
|
+
In real life, YOU add rules using TWO methods:
|
|
635
|
+
|
|
636
|
+
**METHOD 1: Natural Language (RECOMMENDED)** - Tell AI what you need:
|
|
637
|
+
'Customer balance equals sum of order totals for unshipped orders'
|
|
638
|
+
'Balance must not exceed credit limit'
|
|
639
|
+
|
|
640
|
+
AI generates the rules for YOUR schema, whatever column names you have.
|
|
641
|
+
|
|
642
|
+
**Example:** Open logic/declare_logic.py and look at the natural language comments
|
|
643
|
+
between '# Logic from GenAI' markers. These nat lang requirements translate directly
|
|
644
|
+
to the 5 rules you just saw execute. This is Method 1 in action - requirements as code.
|
|
645
|
+
|
|
646
|
+
**METHOD 2: IDE Code Completion** - Type 'Rule.' and see all patterns:
|
|
647
|
+
- Rule.formula
|
|
648
|
+
- Rule.sum
|
|
649
|
+
- Rule.constraint
|
|
650
|
+
- Rule.copy
|
|
651
|
+
|
|
652
|
+
Use when you know exactly what you want and want full control.
|
|
653
|
+
|
|
654
|
+
**WHERE to put the rules? Two locations:**
|
|
655
|
+
|
|
656
|
+
**logic/declare_logic.py** - Main rules file (what we showed you today)
|
|
657
|
+
- All rules in one place
|
|
658
|
+
- Good for simple projects
|
|
659
|
+
|
|
660
|
+
**logic/logic_discovery/*.py** - Organized by use case:
|
|
661
|
+
- logic/logic_discovery/check_credit.py
|
|
662
|
+
- logic/logic_discovery/pricing_rules.py
|
|
663
|
+
- logic/logic_discovery/approval_workflow.py
|
|
664
|
+
- Each file = one business requirement
|
|
665
|
+
- Self-documenting, easy to find
|
|
666
|
+
- Discovery files auto-load at startup
|
|
667
|
+
|
|
668
|
+
**Both methods (natural language OR IDE) work in EITHER location.**
|
|
669
|
+
|
|
670
|
+
The key: You declare WHAT, engine handles WHEN and ORDER.
|
|
671
|
+
|
|
672
|
+
For complete details, see logic/readme_logic.md in this project."
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
**⚠️ Wait for user acknowledgment before moving to Section 4:**
|
|
676
|
+
|
|
677
|
+
```
|
|
678
|
+
Type 'next' when ready to continue to Python integration, or ask questions about how to add logic."
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
---
|
|
682
|
+
|
|
683
|
+
### **Section 4: Iterate with Python (8 min)**
|
|
684
|
+
|
|
685
|
+
**Follow readme.md Section 5**
|
|
686
|
+
|
|
687
|
+
**⚠️ CRITICAL CHOREOGRAPHY CHECKPOINT:**
|
|
688
|
+
- Server MUST be stopped before running add-cust
|
|
689
|
+
- Commands MUST run in this exact order: add-cust, then rebuild-from-database
|
|
690
|
+
- Server MUST be restarted after commands complete
|
|
691
|
+
- Breakpoint MUST be set BEFORE starting server
|
|
692
|
+
- UI navigation MUST follow exact path: Alice → first Order → Add New Item → Lookup
|
|
693
|
+
|
|
694
|
+
**What to Emphasize:**
|
|
695
|
+
```
|
|
696
|
+
"Section 4 - mixing rules with Python for complex logic.
|
|
697
|
+
|
|
698
|
+
New requirement: Give a 10% discount for carbon-neutral products for 10 items or more.
|
|
699
|
+
|
|
700
|
+
We're going to:
|
|
701
|
+
1. Update the schema and database/models.py to add CarbonNeutral column
|
|
702
|
+
(In real life, I can help you make schema changes, or you can do it yourself as described here:
|
|
703
|
+
https://apilogicserver.github.io/Docs/Database-Changes/)
|
|
704
|
+
2. Add discount logic mixing rules + Python
|
|
705
|
+
3. Debug it with breakpoints
|
|
706
|
+
|
|
707
|
+
For this tour, we'll use add-cust to make the changes quickly.
|
|
708
|
+
|
|
709
|
+
First, stop the server (Red Stop button or Shift-F5).
|
|
710
|
+
|
|
711
|
+
Now run these commands:"
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
**⚠️ YOU MUST run both commands in the terminal in this order:**
|
|
715
|
+
```bash
|
|
716
|
+
genai-logic add-cust
|
|
717
|
+
genai-logic rebuild-from-database --db_url=sqlite:///database/db.sqlite
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
**After commands complete:**
|
|
721
|
+
```
|
|
722
|
+
"Done! This:
|
|
723
|
+
- Updated database with Product.CarbonNeutral column
|
|
724
|
+
- Rebuilt models.py to include the new column
|
|
725
|
+
- Updated logic/declare_logic.py with the discount logic
|
|
726
|
+
|
|
727
|
+
You can ignore the warning about 'mcp-SysMcp' - not present.
|
|
728
|
+
|
|
729
|
+
Type 'ready' when you've reviewed the console output."
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
**⚠️ DO NOT proceed until user confirms**
|
|
733
|
+
|
|
734
|
+
**Set Breakpoint and Debug:**
|
|
735
|
+
```
|
|
736
|
+
"Open logic/declare_logic.py, scroll to the derive_amount function.
|
|
737
|
+
|
|
738
|
+
Set a breakpoint on the line with 'if row.Product.CarbonNeutral...'
|
|
739
|
+
|
|
740
|
+
⚠️ IMPORTANT: Set the breakpoint BEFORE starting the server.
|
|
741
|
+
|
|
742
|
+
Start the server (F5).
|
|
743
|
+
|
|
744
|
+
Now go to admin app, login as admin.
|
|
745
|
+
|
|
746
|
+
Find Customer Alice, drill into her first Order, and click 'Add New Item'.
|
|
747
|
+
|
|
748
|
+
Use the Lookup function to select a Green product (Product ID 1 or 5).
|
|
749
|
+
|
|
750
|
+
Set quantity to 12 and save.
|
|
751
|
+
|
|
752
|
+
Breakpoint hits!
|
|
753
|
+
|
|
754
|
+
👉 Look at VS Code LOCALS pane (left side).
|
|
755
|
+
👉 See row, row.quantity, row.Product, row.Product.CarbonNeutral?
|
|
756
|
+
|
|
757
|
+
This is live debugging with real data. Not magic - transparent Python code you can step through.
|
|
758
|
+
|
|
759
|
+
👉 Open DEBUG CONSOLE (bottom panel).
|
|
760
|
+
Type: row.Product.CarbonNeutral
|
|
761
|
+
Type: row.quantity
|
|
762
|
+
|
|
763
|
+
You're inspecting the exact state that triggered this rule.
|
|
764
|
+
|
|
765
|
+
Press F10 to step through - see the 10% discount calculation.
|
|
766
|
+
Press F5 to continue.
|
|
767
|
+
|
|
768
|
+
Check the Item amount - it got the discount automatically."
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
**The Key Teaching Moments:**
|
|
772
|
+
```
|
|
773
|
+
"Three big insights here:
|
|
774
|
+
|
|
775
|
+
1. **Rules + Python Mix**:
|
|
776
|
+
- Rule.formula calls Python function (derive_amount)
|
|
777
|
+
- Python has complex if/else logic inside
|
|
778
|
+
- Still gets automatic chaining (no explicit calls needed)
|
|
779
|
+
|
|
780
|
+
2. **Parent References Work Automatically**:
|
|
781
|
+
- row.Product.CarbonNeutral does the SQL join for you
|
|
782
|
+
- No query writing, no ORM gymnastics
|
|
783
|
+
- Think in business terms, engine handles SQL
|
|
784
|
+
|
|
785
|
+
3. **Debugging Transparency**:
|
|
786
|
+
- Set breakpoints, inspect locals, use debug console
|
|
787
|
+
- Not a black box - you SEE the data, STEP through logic
|
|
788
|
+
- Check the console log - see the rules that already fired
|
|
789
|
+
- Answers "how did I get here?" - the complete execution chain
|
|
790
|
+
- This is how you'll diagnose issues in YOUR projects
|
|
791
|
+
|
|
792
|
+
The pattern: Use rules for 95% (sums, copies, formulas), use Python for complex 5% (conditionals, API calls).
|
|
793
|
+
You get best of both: declarative power + procedural flexibility."
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
**Schema Evolution Note:**
|
|
797
|
+
```
|
|
798
|
+
"Notice what just happened with rebuild-from-database:
|
|
799
|
+
- Database had new column added (by add-cust)
|
|
800
|
+
- Rebuild regenerated models.py automatically
|
|
801
|
+
- No manual ALTER TABLE, no migration scripts
|
|
802
|
+
- Database integrity maintained (foreign keys, constraints intact)
|
|
803
|
+
|
|
804
|
+
This is the workflow for schema changes:
|
|
805
|
+
1. Modify database (SQL, add-cust, or DB tool)
|
|
806
|
+
2. Run rebuild-from-database
|
|
807
|
+
3. Models.py updated, relationships preserved
|
|
808
|
+
4. Continue coding
|
|
809
|
+
|
|
810
|
+
Handles real-world evolution without breaking things."
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
---
|
|
814
|
+
|
|
815
|
+
### **Section 5: B2B Integration (10 min)**
|
|
816
|
+
|
|
817
|
+
**Set the Stage:**
|
|
818
|
+
|
|
819
|
+
**What to Say:**
|
|
820
|
+
```
|
|
821
|
+
"Section 5 - B2B Integration.
|
|
822
|
+
|
|
823
|
+
Real-world scenario: You now want to build integrations with:
|
|
824
|
+
1. Your customers - they need a custom API to POST orders in their format
|
|
825
|
+
2. Internal systems - you want to post Kafka messages when orders ship
|
|
826
|
+
|
|
827
|
+
Two big patterns to show you..."
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
#### **Part A: Custom APIs (5 min)**
|
|
831
|
+
|
|
832
|
+
**What to Emphasize:**
|
|
833
|
+
```
|
|
834
|
+
"First: CUSTOM APIs for partner integrations.
|
|
835
|
+
|
|
836
|
+
The first add-cust command already created api/api_discovery/order_b2b.py -
|
|
837
|
+
a custom endpoint that accepts partner-specific JSON format and maps it to our Order/Item structure.
|
|
838
|
+
|
|
839
|
+
Let's test it first, then look at the code..."
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
**Test the Endpoint:**
|
|
843
|
+
```
|
|
844
|
+
"Open Swagger (Home → Swagger link).
|
|
845
|
+
|
|
846
|
+
Find 'ServicesEndPoint' section, expand POST /ServicesEndPoint/OrderB2B.
|
|
847
|
+
|
|
848
|
+
Click 'Try it out', use the prefilled example JSON, Execute.
|
|
849
|
+
|
|
850
|
+
See the response? Order created with Items, rules fired automatically.
|
|
851
|
+
|
|
852
|
+
Now check the logic log in VS Code console - see all those 'Logic Bank' lines?
|
|
853
|
+
|
|
854
|
+
👉 The custom API mapped partner format to our models
|
|
855
|
+
👉 Rules enforced automatically - whether from UI app or custom API
|
|
856
|
+
👉 Zero duplication of logic - reuse over transactions and sources
|
|
857
|
+
|
|
858
|
+
Type 'done' when you've seen the response and console log."
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
**Show the Code:**
|
|
862
|
+
```
|
|
863
|
+
"Now let's look at the code.
|
|
864
|
+
|
|
865
|
+
Open [`api/api_discovery/order_b2b.py`](api/api_discovery/order_b2b.py).
|
|
866
|
+
|
|
867
|
+
See how it works:
|
|
868
|
+
1. Uses api.expose_object(ServicesEndPoint) to register the API class
|
|
869
|
+
2. Accepts partner JSON structure (different field names, different nesting)
|
|
870
|
+
3. Calls RowDictMapper.insert() to transform and insert
|
|
871
|
+
4. Returns response
|
|
872
|
+
|
|
873
|
+
The mapping logic is in integration/row_dict_maps/OrderB2B.py -
|
|
874
|
+
separates API shape from business logic.
|
|
875
|
+
|
|
876
|
+
**Key insight: The API code is short (30 lines) because the logic is automatically reused.**
|
|
877
|
+
No duplication - the same balance check, discount calculation, and totals that work in the UI
|
|
878
|
+
automatically apply here. This is why you can support multiple channels without multiplying your code.
|
|
879
|
+
|
|
880
|
+
Important point: You can code this yourself, OR you can ask your AI assistant to create it.
|
|
881
|
+
For example: 'Create a custom API endpoint that accepts orders with this JSON structure...'
|
|
882
|
+
The AI can generate this pattern for you.
|
|
883
|
+
|
|
884
|
+
Pattern: Custom APIs + row mappers + automatic rule enforcement."
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
#### **Part B: Logic Extensions (5 min)**
|
|
888
|
+
|
|
889
|
+
**What to Emphasize:**
|
|
890
|
+
```
|
|
891
|
+
"Second big idea: LOGIC EXTENSIONS for side effects.
|
|
892
|
+
|
|
893
|
+
Open logic/declare_logic.py, scroll to the send_order_to_shipping function.
|
|
894
|
+
|
|
895
|
+
See this function?
|
|
896
|
+
|
|
897
|
+
This uses after_flush_row_event - triggers AFTER transaction commits.
|
|
898
|
+
|
|
899
|
+
Pattern:
|
|
900
|
+
- Order placed, items added, rules fire (balance check, totals)
|
|
901
|
+
- Transaction about to commit
|
|
902
|
+
- This extension fires: 'hey, send message to shipping system'
|
|
903
|
+
- Uses Kafka producer (commented out here, but shows the pattern)
|
|
904
|
+
|
|
905
|
+
Why after_flush? Because you only want to notify AFTER data is committed.
|
|
906
|
+
If transaction rolls back, message never sends. Transactional consistency."
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
**The Integration Pattern:**
|
|
910
|
+
```
|
|
911
|
+
"This is how you integrate with external systems:
|
|
912
|
+
|
|
913
|
+
1. Core logic as rules (balance, totals, constraints)
|
|
914
|
+
2. Extensions for side effects (send message, call API, write audit log)
|
|
915
|
+
3. Extensions use row_events: before_flush, after_flush, etc.
|
|
916
|
+
|
|
917
|
+
Examples:
|
|
918
|
+
- after_flush: Send Kafka message (like here)
|
|
919
|
+
- after_flush: Call shipping API
|
|
920
|
+
- before_flush: Write audit trail
|
|
921
|
+
- after_update: Sync to data warehouse
|
|
922
|
+
|
|
923
|
+
The pattern keeps business logic (rules) separate from integration glue (extensions).
|
|
924
|
+
|
|
925
|
+
Both automatic, both declarative, both in same file."
|
|
926
|
+
```
|
|
927
|
+
|
|
928
|
+
**The Big Picture:**
|
|
929
|
+
```
|
|
930
|
+
"So B2B integration has two patterns:
|
|
931
|
+
|
|
932
|
+
1. **Custom APIs**: Accept partner formats, map to models, rules enforce
|
|
933
|
+
2. **Logic Extensions**: After core logic, trigger side effects
|
|
934
|
+
|
|
935
|
+
Together they handle:
|
|
936
|
+
- Multiple client formats (REST, GraphQL, partners)
|
|
937
|
+
- External system notifications (Kafka, webhooks, APIs)
|
|
938
|
+
- All using same rule enforcement (no duplication)
|
|
939
|
+
|
|
940
|
+
That's why logic is reusable - write once, works everywhere."
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
**⚠️ Wait for user acknowledgment before wrap-up:**
|
|
944
|
+
|
|
945
|
+
```
|
|
946
|
+
Type 'next' when ready for the wrap-up and metrics, or ask questions about B2B integration."
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
---
|
|
950
|
+
|
|
951
|
+
### **Post-Tour: Wrap-Up & Metrics (5 min)**
|
|
952
|
+
|
|
953
|
+
#### **Part 1: What We Saw**
|
|
954
|
+
|
|
955
|
+
**The Transition:**
|
|
956
|
+
```
|
|
957
|
+
"Okay, you just walked around the block.
|
|
958
|
+
|
|
959
|
+
Quick recap of what you SAW:
|
|
960
|
+
✅ Auto-generated API and Admin App (with MCP server for Claude Desktop)
|
|
961
|
+
✅ 5 declarative rules = check credit logic
|
|
962
|
+
✅ Rules fired automatically with dependency ordering (logic log showed the chain)
|
|
963
|
+
✅ Pattern: Constrain a Derived Result (aggregate up, constrain at top)
|
|
964
|
+
✅ Security role-based filtering (6 customers → 3 for sales role)
|
|
965
|
+
✅ Rules + Python mix (discount logic with debugging)
|
|
966
|
+
✅ Schema evolution (CarbonNeutral column, rebuild-from-database)
|
|
967
|
+
✅ Custom APIs (B2B OrderB2B endpoint with partner format)
|
|
968
|
+
✅ Logic Extensions (Kafka send_order_to_shipping pattern)
|
|
969
|
+
|
|
970
|
+
Type 'next' when ready for the underlying tech advantage, or ask questions about what we saw."
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
**⚠️ DO NOT proceed until user types 'next'**
|
|
974
|
+
|
|
975
|
+
---
|
|
976
|
+
|
|
977
|
+
#### **Part 2: The Code Metrics**
|
|
978
|
+
|
|
979
|
+
**The Code Metrics Reveal:**
|
|
980
|
+
```
|
|
981
|
+
"Now here's the question that ties it all together:
|
|
982
|
+
|
|
983
|
+
👉 How much custom code was actually introduced?"
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
```
|
|
987
|
+
"Let's count. Open logic/declare_logic.py:
|
|
988
|
+
|
|
989
|
+
Lines 39-63: The 5 declarative rules + comments ≈ 23 lines
|
|
990
|
+
Lines 51-58: derive_amount Python function ≈ 8 lines
|
|
991
|
+
Lines 68-84: send_order_to_shipping Python function ≈ 17 lines
|
|
992
|
+
|
|
993
|
+
Total custom logic: ~48 lines (23 declarative + 25 Python)
|
|
994
|
+
|
|
995
|
+
Now think about the procedural equivalent:
|
|
996
|
+
- Handle Item insert/update/delete → recalc amount
|
|
997
|
+
- Find parent Order → recalc total
|
|
998
|
+
- Handle Item FK changes (moves to different Order)
|
|
999
|
+
- Find parent Customer → recalc balance
|
|
1000
|
+
- Handle Order FK changes (moves to different Customer)
|
|
1001
|
+
- Check constraint on every balance change
|
|
1002
|
+
- Handle all 3 operations (insert/update/delete) × 3 entities
|
|
1003
|
+
- Discount logic with product join
|
|
1004
|
+
- Kafka integration with transaction coordination
|
|
1005
|
+
|
|
1006
|
+
Conservative estimate: 200+ lines of procedural code.
|
|
1007
|
+
|
|
1008
|
+
You just saw 48 lines replace 200+. That's the 40X productivity claim - with concrete numbers.
|
|
1009
|
+
|
|
1010
|
+
And remember:
|
|
1011
|
+
- Zero corner case bugs (automatic chaining handles all FK changes)
|
|
1012
|
+
- Zero maintenance archaeology (declarative rules are self-documenting)
|
|
1013
|
+
- Debugging transparency (breakpoints, locals, debug console)
|
|
1014
|
+
|
|
1015
|
+
That's why it's called declarative logic - you declare WHAT, engine handles WHEN and HOW.
|
|
1016
|
+
|
|
1017
|
+
---
|
|
1018
|
+
|
|
1019
|
+
**Want to see the actual procedural version?**
|
|
1020
|
+
|
|
1021
|
+
```
|
|
1022
|
+
"We ran an experiment - asked AI to rebuild this same logic procedurally, without rules.
|
|
1023
|
+
|
|
1024
|
+
Open logic/procedural/declarative-vs-procedural-comparison.md - let's look at it real quick.
|
|
1025
|
+
|
|
1026
|
+
Type 'opened' when you have the comparison document visible.
|
|
1027
|
+
|
|
1028
|
+
See the TL;DR table? 5 lines declarative vs 220+ procedural. That's the code volume.
|
|
1029
|
+
|
|
1030
|
+
But scroll down to the actual procedural code sample...
|
|
1031
|
+
|
|
1032
|
+
See those comments - 'CRITICAL BUG FIX'?
|
|
1033
|
+
|
|
1034
|
+
AI initially MISSED product-id changes. Fixed it.
|
|
1035
|
+
Then MISSED order-id changes. Fixed that too.
|
|
1036
|
+
Multiple bug cycles just to get basic logic working.
|
|
1037
|
+
|
|
1038
|
+
The declarative version? Zero bugs. Worked first time.
|
|
1039
|
+
|
|
1040
|
+
Why? Because you listed WHAT you want (5 rules).
|
|
1041
|
+
Engine handles ALL the scenarios - insert, update, delete, FK changes, old/new values.
|
|
1042
|
+
|
|
1043
|
+
You don't forget edge cases. The engine doesn't forget them either.
|
|
1044
|
+
|
|
1045
|
+
That's 2 minutes - we can dig deeper in Q&A if you want,
|
|
1046
|
+
but this shows why automatic chaining isn't just convenient - it's CORRECT."
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
---
|
|
1050
|
+
|
|
1051
|
+
## Post-Tour: Open Q&A (10-25 min)
|
|
1052
|
+
|
|
1053
|
+
### **The Transition:**
|
|
1054
|
+
```
|
|
1055
|
+
"Okay - you just walked through the complete tour. We're about 35 minutes in.
|
|
1056
|
+
|
|
1057
|
+
Now - parked questions. What do you want to dig into?
|
|
1058
|
+
- How engine discovers dependencies?
|
|
1059
|
+
- When to use Python vs pure rules?
|
|
1060
|
+
- How to add new rules?
|
|
1061
|
+
- Testing approach?
|
|
1062
|
+
- Something else?"
|
|
1063
|
+
```
|
|
1064
|
+
|
|
1065
|
+
### **Common Follow-up Questions:**
|
|
1066
|
+
|
|
1067
|
+
#### **Q: "How does the engine know the order?"**
|
|
1068
|
+
```
|
|
1069
|
+
A: "Dependency discovery - analyzes what attributes each rule uses.
|
|
1070
|
+
|
|
1071
|
+
Example:
|
|
1072
|
+
- Item.amount uses quantity, unit_price
|
|
1073
|
+
- Order.amount_total uses Item.amount
|
|
1074
|
+
- Customer.balance uses Order.amount_total
|
|
1075
|
+
|
|
1076
|
+
Engine builds dependency graph: Item → Order → Customer
|
|
1077
|
+
|
|
1078
|
+
When Item.quantity changes:
|
|
1079
|
+
1. Item.amount recalcs (depends on quantity)
|
|
1080
|
+
2. Order.amount_total recalcs (depends on Item.amount)
|
|
1081
|
+
3. Customer.balance recalcs (depends on Order.amount_total)
|
|
1082
|
+
4. Constraint checks (depends on balance)
|
|
1083
|
+
|
|
1084
|
+
That's the automatic ordering. You don't specify it - engine discovers it.
|
|
1085
|
+
|
|
1086
|
+
Want to see the dependency graph? There's a rules report..."
|
|
1087
|
+
```
|
|
1088
|
+
|
|
1089
|
+
#### **Q: "When should I use Python instead of rules?"**
|
|
1090
|
+
```
|
|
1091
|
+
A: "Rule of thumb:
|
|
1092
|
+
|
|
1093
|
+
USE RULES for:
|
|
1094
|
+
- Derivations (sum, count, formula, copy)
|
|
1095
|
+
- Simple constraints (balance <= credit_limit)
|
|
1096
|
+
- Parent references (Item.unit_price from Product)
|
|
1097
|
+
|
|
1098
|
+
USE PYTHON for:
|
|
1099
|
+
- Complex conditionals (if this AND that OR other)
|
|
1100
|
+
- External API calls
|
|
1101
|
+
- String parsing/formatting
|
|
1102
|
+
- Date calculations beyond simple stamps
|
|
1103
|
+
- Custom algorithms
|
|
1104
|
+
|
|
1105
|
+
The discount example shows the mix:
|
|
1106
|
+
- Rules handle the formula trigger
|
|
1107
|
+
- Python handles the if/else logic
|
|
1108
|
+
- Rules handle the chaining
|
|
1109
|
+
|
|
1110
|
+
Most systems: 40% rules, 5% Python, 55% auto-generated."
|
|
1111
|
+
```
|
|
1112
|
+
|
|
1113
|
+
#### **Q: "How do I test this?"**
|
|
1114
|
+
```
|
|
1115
|
+
A: "Two approaches:
|
|
1116
|
+
|
|
1117
|
+
1. Manual testing (what you just did)
|
|
1118
|
+
- Use admin app or Swagger
|
|
1119
|
+
- Watch logic log in console
|
|
1120
|
+
- Verify expected behavior
|
|
1121
|
+
|
|
1122
|
+
2. Automated testing (Behave)
|
|
1123
|
+
- Write scenarios in plain English
|
|
1124
|
+
- Tests execute against running server
|
|
1125
|
+
- Generates logic report showing which rules fired
|
|
1126
|
+
|
|
1127
|
+
Check readme section on testing, or:
|
|
1128
|
+
docs/training/testing.md in the project.
|
|
1129
|
+
|
|
1130
|
+
Want to write a test together?"
|
|
1131
|
+
```
|
|
1132
|
+
|
|
1133
|
+
#### **Q: "Can I see the rule patterns again?"**
|
|
1134
|
+
```
|
|
1135
|
+
A: "Yes - keep this open as reference:
|
|
1136
|
+
https://apilogicserver.github.io/Docs/Logic/#rule-patterns
|
|
1137
|
+
|
|
1138
|
+
The 'Rule Patterns' table is your cheat sheet.
|
|
1139
|
+
|
|
1140
|
+
Also check the 'Rules Case Study' section below it -
|
|
1141
|
+
shows how to design solutions using patterns.
|
|
1142
|
+
|
|
1143
|
+
And in your project: system/genai/examples/ folder
|
|
1144
|
+
shows training examples for these patterns."
|
|
1145
|
+
```
|
|
1146
|
+
|
|
1147
|
+
---
|
|
1148
|
+
|
|
1149
|
+
## Readiness Check (Conversational)
|
|
1150
|
+
|
|
1151
|
+
### **Not a Quiz - A Scenario:**
|
|
1152
|
+
|
|
1153
|
+
```
|
|
1154
|
+
"Let's try a scenario together - conversational, not a test.
|
|
1155
|
+
|
|
1156
|
+
Scenario:
|
|
1157
|
+
'Sales reps earn commission:
|
|
1158
|
+
- 3% of order total
|
|
1159
|
+
- Only on shipped orders
|
|
1160
|
+
- Rep.total_commission = sum of their order commissions'
|
|
1161
|
+
|
|
1162
|
+
Don't write code yet - just tell me your approach.
|
|
1163
|
+
What rules would you use? What pattern is this?"
|
|
1164
|
+
```
|
|
1165
|
+
|
|
1166
|
+
### **What You're Listening For:**
|
|
1167
|
+
|
|
1168
|
+
✅ **They get it:**
|
|
1169
|
+
```
|
|
1170
|
+
"Need Rep.total_commission column...
|
|
1171
|
+
Then Rule.sum with where shipped...
|
|
1172
|
+
And Rule.formula for 3% of order total...
|
|
1173
|
+
That's Chain Up - aggregate then use it."
|
|
1174
|
+
```
|
|
1175
|
+
|
|
1176
|
+
✅ **Needs more time:**
|
|
1177
|
+
```
|
|
1178
|
+
"I'd write a function that loops through orders..."
|
|
1179
|
+
→ They're thinking procedurally, not declaratively
|
|
1180
|
+
→ Needs more pattern examples
|
|
1181
|
+
```
|
|
1182
|
+
|
|
1183
|
+
✅ **Partial understanding:**
|
|
1184
|
+
```
|
|
1185
|
+
"Use a sum rule? But how do I calculate commission?"
|
|
1186
|
+
→ They get aggregation, need formula pattern
|
|
1187
|
+
→ Show: Rule.formula for commission, then sum the formulas
|
|
1188
|
+
```
|
|
1189
|
+
|
|
1190
|
+
### **The Follow-up:**
|
|
1191
|
+
|
|
1192
|
+
```
|
|
1193
|
+
"Good! You're thinking in patterns.
|
|
1194
|
+
|
|
1195
|
+
Here's the code (roughly):
|
|
1196
|
+
|
|
1197
|
+
# Pattern: Chain Down (copy rep to order)
|
|
1198
|
+
Rule.copy(derive=Order.sales_rep_id, from_parent=Rep.id)
|
|
1199
|
+
|
|
1200
|
+
# Pattern: Formula (calculate commission)
|
|
1201
|
+
Rule.formula(derive=Order.commission,
|
|
1202
|
+
as_expression=lambda row: row.amount_total * Decimal('0.03')
|
|
1203
|
+
if row.date_shipped else 0)
|
|
1204
|
+
|
|
1205
|
+
# Pattern: Chain Up (aggregate commissions)
|
|
1206
|
+
Rule.sum(derive=Rep.total_commission,
|
|
1207
|
+
as_sum_of=Order.commission,
|
|
1208
|
+
where=lambda row: row.date_shipped is not None)
|
|
1209
|
+
|
|
1210
|
+
See how patterns compose?
|
|
1211
|
+
- Copy (Chain Down) links order to rep
|
|
1212
|
+
- Formula calculates individual commission
|
|
1213
|
+
- Sum (Chain Up) aggregates to rep total
|
|
1214
|
+
|
|
1215
|
+
That's the power - patterns are building blocks."
|
|
1216
|
+
```
|
|
1217
|
+
|
|
1218
|
+
---
|
|
1219
|
+
|
|
1220
|
+
## Level-2: Next Steps
|
|
1221
|
+
|
|
1222
|
+
### **When They're Ready:**
|
|
1223
|
+
|
|
1224
|
+
```
|
|
1225
|
+
"You've got the basics:
|
|
1226
|
+
✅ Rules fire automatically
|
|
1227
|
+
✅ Pattern recognition (Chain Up, Counts, etc.)
|
|
1228
|
+
✅ Rules + Python mix
|
|
1229
|
+
✅ Logic log debugging
|
|
1230
|
+
✅ Security basics
|
|
1231
|
+
|
|
1232
|
+
Ready for more advanced patterns? There's nw_sample with:
|
|
1233
|
+
- B2B integration APIs (RowDictMapper)
|
|
1234
|
+
- Kafka row events
|
|
1235
|
+
- State transition logic (old_row)
|
|
1236
|
+
- Audit logging (copy_row)
|
|
1237
|
+
- Testing with Behave
|
|
1238
|
+
|
|
1239
|
+
Want to continue, or need more time with basic_demo?"
|
|
1240
|
+
```
|
|
1241
|
+
|
|
1242
|
+
### **Level-2 Readiness Signals:**
|
|
1243
|
+
|
|
1244
|
+
✅ **They're asking about:**
|
|
1245
|
+
- "How do I integrate with external systems?"
|
|
1246
|
+
- "Can I track changes to data?"
|
|
1247
|
+
- "How do I handle workflows?"
|
|
1248
|
+
- "What about event-driven architecture?"
|
|
1249
|
+
|
|
1250
|
+
✅ **They're comfortable with:**
|
|
1251
|
+
- Reading logic logs without help
|
|
1252
|
+
- Naming patterns when they see them
|
|
1253
|
+
- Designing simple scenarios independently
|
|
1254
|
+
- Mixing rules and Python appropriately
|
|
1255
|
+
|
|
1256
|
+
⏸️ **They're NOT ready if:**
|
|
1257
|
+
- Still confused about automatic invocation
|
|
1258
|
+
- Can't read logic log output
|
|
1259
|
+
- Don't understand pattern names
|
|
1260
|
+
- Think they need to "call" the rules
|
|
1261
|
+
|
|
1262
|
+
**Recommendation:** If not ready, do 1-2 more scenarios together in basic_demo before advancing.
|
|
1263
|
+
|
|
1264
|
+
---
|
|
1265
|
+
|
|
1266
|
+
## Key Principles for AI Tour Guides
|
|
1267
|
+
|
|
1268
|
+
### **Use Conversational Tone:**
|
|
1269
|
+
|
|
1270
|
+
✅ **DO:** Use "I" and "you" - personal and engaging
|
|
1271
|
+
- "I'll show you..."
|
|
1272
|
+
- "You'll see..."
|
|
1273
|
+
- "Let's explore..."
|
|
1274
|
+
|
|
1275
|
+
❌ **DON'T:** Use third-person references
|
|
1276
|
+
- "The user will..."
|
|
1277
|
+
- "Users should..."
|
|
1278
|
+
- "One can observe..."
|
|
1279
|
+
|
|
1280
|
+
### **Keep Responses Short:**
|
|
1281
|
+
|
|
1282
|
+
✅ **DO:** One idea/insight per interaction
|
|
1283
|
+
- Users often have Copilot in side panel (limited vertical space)
|
|
1284
|
+
- Avoid walls of text that scroll off screen
|
|
1285
|
+
- Make each response fit on a 16" laptop screen with side panel
|
|
1286
|
+
|
|
1287
|
+
❌ **DON'T:** Dump multiple concepts at once
|
|
1288
|
+
- Long explanations that require scrolling
|
|
1289
|
+
- Multiple sections in one response
|
|
1290
|
+
|
|
1291
|
+
### **Balance Questions:**
|
|
1292
|
+
|
|
1293
|
+
**Explain Now:**
|
|
1294
|
+
- Clarifies current step
|
|
1295
|
+
- Simple, quick answer
|
|
1296
|
+
- Helps understanding of what they're seeing
|
|
1297
|
+
|
|
1298
|
+
**Park for Later:**
|
|
1299
|
+
- Deep technical details
|
|
1300
|
+
- Unrelated to current section
|
|
1301
|
+
- Would derail momentum
|
|
1302
|
+
|
|
1303
|
+
### **Provocations Work:**
|
|
1304
|
+
|
|
1305
|
+
Don't just show → Make them discover:
|
|
1306
|
+
- "What do you think happened?"
|
|
1307
|
+
- "Where's the code that did that?"
|
|
1308
|
+
- "How would YOU solve this?"
|
|
1309
|
+
- "See the pattern?"
|
|
1310
|
+
|
|
1311
|
+
### **Name the Patterns:**
|
|
1312
|
+
|
|
1313
|
+
Every time you show something, name it:
|
|
1314
|
+
- "That's Chain Up"
|
|
1315
|
+
- "This is the Counts pattern"
|
|
1316
|
+
- "Here's Chain Down in action"
|
|
1317
|
+
|
|
1318
|
+
Repetition builds recognition.
|
|
1319
|
+
|
|
1320
|
+
### **Logic Log is Sacred:**
|
|
1321
|
+
|
|
1322
|
+
Always emphasize:
|
|
1323
|
+
- "Look at the logic log"
|
|
1324
|
+
- "See the indentation?"
|
|
1325
|
+
- "Count the rules firing"
|
|
1326
|
+
|
|
1327
|
+
They MUST learn to read this - it's their debugging tool.
|
|
1328
|
+
|
|
1329
|
+
### **Pattern Reference is Key:**
|
|
1330
|
+
|
|
1331
|
+
Keep pointing back to:
|
|
1332
|
+
- Rule Patterns doc table
|
|
1333
|
+
- "You'll use this constantly"
|
|
1334
|
+
- "Which pattern applies here?"
|
|
1335
|
+
|
|
1336
|
+
Build the habit of pattern-first thinking.
|
|
1337
|
+
|
|
1338
|
+
---
|
|
1339
|
+
|
|
1340
|
+
## What's Next: Explore AI-Assisted Development (Vibe)
|
|
1341
|
+
|
|
1342
|
+
**You've completed the guided tour!** You've learned:
|
|
1343
|
+
- How rules work (automatic chaining, multi-table logic)
|
|
1344
|
+
- Pattern-based thinking (Chain Up, Counts, Copy, Formula)
|
|
1345
|
+
- Debugging with logic log and breakpoints
|
|
1346
|
+
- Testing with Behave
|
|
1347
|
+
|
|
1348
|
+
**Now you're ready for the next level:** AI-assisted development with **Vibe**.
|
|
1349
|
+
|
|
1350
|
+
### From Structured to Exploratory
|
|
1351
|
+
|
|
1352
|
+
**What you just did:** Structured learning with safety net (tutor guided you)
|
|
1353
|
+
**What's next:** Exploratory development with AI (you guide the AI)
|
|
1354
|
+
|
|
1355
|
+
### The Vibe Demo
|
|
1356
|
+
|
|
1357
|
+
Return to the Manager workspace and use this natural language prompt with Copilot:
|
|
1358
|
+
```
|
|
1359
|
+
Create a database project named basic_demo_vibe from samples/dbs/basic_demo.sqlite
|
|
1360
|
+
```
|
|
1361
|
+
|
|
1362
|
+
Then, in the new project, follow `readme_vibe.md` to explore:
|
|
1363
|
+
|
|
1364
|
+
1. **Custom React Apps** - Use `genai-add-app` to create UI with natural language, then add maps, trees etc
|
|
1365
|
+
2. **B2B Integration** - Build custom API endpoints for partner systems with vibe
|
|
1366
|
+
3. **MCP Implementation** - Enable business users to query/update with natural language
|
|
1367
|
+
4. **AI-Driven Development** - Let Copilot generate code, embrace errors, insist on fixes
|
|
1368
|
+
|
|
1369
|
+
### Vibe Philosophy
|
|
1370
|
+
|
|
1371
|
+
**Different approach:**
|
|
1372
|
+
- AI makes errors → That's expected
|
|
1373
|
+
- You tell Copilot: "Error X occurred, fix it"
|
|
1374
|
+
- Copilot finds and corrects mistakes
|
|
1375
|
+
- Exploratory, not scripted
|
|
1376
|
+
|
|
1377
|
+
**Why this works now:**
|
|
1378
|
+
- You understand what's happening "under the hood"
|
|
1379
|
+
- You can evaluate AI-generated code quality
|
|
1380
|
+
- You know when it's an AI mistake vs platform issue
|
|
1381
|
+
- You have pattern vocabulary to guide the AI
|
|
1382
|
+
|
|
1383
|
+
### When You're Ready
|
|
1384
|
+
|
|
1385
|
+
Close this project, return to Manager, and start the Vibe demo. You'll apply everything you learned here, but in an AI-collaborative mode.
|
|
1386
|
+
|
|
1387
|
+
**Pro tip:** The foundation you built here makes Vibe more productive - you can spot AI mistakes faster and guide it to correct patterns.
|
|
1388
|
+
|
|
1389
|
+
---
|
|
1390
|
+
|
|
1391
|
+
## Success Criteria
|
|
1392
|
+
|
|
1393
|
+
### **They're Ready When They Can:**
|
|
1394
|
+
|
|
1395
|
+
□ Explain automatic rule invocation ("engine discovers dependencies")
|
|
1396
|
+
□ Read logic log and identify rule chaining
|
|
1397
|
+
□ Name at least 2 patterns (Chain Up, Counts)
|
|
1398
|
+
□ Explain when to use Python vs rules
|
|
1399
|
+
□ Design a simple scenario using patterns
|
|
1400
|
+
□ Know where to find pattern reference docs
|
|
1401
|
+
□ Use breakpoint debugging with rules
|
|
1402
|
+
|
|
1403
|
+
### **They Need More Time When They:**
|
|
1404
|
+
|
|
1405
|
+
□ Say "I'd write a function to loop through..."
|
|
1406
|
+
□ Ask "How do I call the rules?"
|
|
1407
|
+
□ Can't identify patterns in scenarios
|
|
1408
|
+
□ Don't understand logic log output
|
|
1409
|
+
□ Think rules are just "shortcuts for code"
|
|
1410
|
+
|
|
1411
|
+
**If more time needed:** Do another scenario walkthrough using pattern lens.
|
|
1412
|
+
|
|
1413
|
+
---
|
|
1414
|
+
|
|
1415
|
+
## Notes for Future Updates
|
|
1416
|
+
|
|
1417
|
+
### **What Works Well:**
|
|
1418
|
+
- The provocation approach (forces discovery)
|
|
1419
|
+
- Logic log emphasis (builds debugging habit)
|
|
1420
|
+
- Pattern naming repetition (builds vocabulary)
|
|
1421
|
+
- Conversational readiness check (better than quiz)
|
|
1422
|
+
|
|
1423
|
+
### **What to Improve:**
|
|
1424
|
+
- [Add learnings from actual guided tour sessions]
|
|
1425
|
+
- [Common stumbling points to address]
|
|
1426
|
+
- [Additional scenarios that worked well]
|
|
1427
|
+
|
|
1428
|
+
### **Resources to Add:**
|
|
1429
|
+
- Video walkthrough following this script
|
|
1430
|
+
- Printable pattern reference card
|
|
1431
|
+
- Common mistakes cheat sheet
|
|
1432
|
+
- Level-2 guided tour checklist
|
|
1433
|
+
|
|
1434
|
+
---
|
|
1435
|
+
|
|
1436
|
+
**Remember:** You're the experienced guide walking them around the neighborhood. You've been here 1000 times. They're seeing it for the first time. Your job: make them DISCOVER the insights, not just hear them.
|