Skip to content

Commit aa7ebb9

Browse files
valhuberclaude
andcommitted
Sync from local-mgr: maintainability framing, item-1-open, credit_service notes
README: existing-db-first quick start, "is this maintainable?" question framing for section 1, business logic as 4th generated artifact, reworded iterate-step rationale, merged AI-assistant-selection/paste-prompt summary line. create_codespaces_mgr.py: item 1's details block now opens by default in Codespaces (reviewer feedback - devs skim code, not prose; first code block shouldn't need a click on a first-time visit). Fixed CS/browser-note injection anchor, which had drifted onto a stale "See it work" match after local-mgr's title rewrite -- re-anchored to the outer "<details>\n<summary>⚡ ..." summary, distinct from the item-1-open patch's anchor. credit_service.py: propagated bug/perf notes from local-mgr's basic_demo_logic_gov. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3a26398 commit aa7ebb9

3 files changed

Lines changed: 60 additions & 16 deletions

File tree

.devcontainer/create_codespaces_mgr.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,11 @@ def main():
255255
readme = readme.lstrip("\n")
256256
print(" ✅ Front matter and style block stripped")
257257

258-
# Inject Codespaces + browser notes inside "See it work" (idempotent)
259-
# Match on the stable "<summary>⚡ See it work" prefix — the text after the
260-
# em-dash is gold-source copy (org_git/Docs) and changes independently of this script.
261-
summary_re = re.compile(r"<summary>⚡ See it work[^<]*</summary>")
258+
# Inject Codespaces + browser notes right after the outer "First Time Here?" details
259+
# summary (idempotent). Match on the stable "<details>\n<summary>⚡ ...</summary>" prefix —
260+
# the text after the lightning bolt is gold-source copy (org_git/Docs) and changes
261+
# independently of this script.
262+
summary_re = re.compile(r"<details>\n<summary>⚡[^<]*</summary>")
262263
if "Use Chrome or Edge" not in readme:
263264
cs_note = (
264265
"\n&nbsp;\n\n"
@@ -269,14 +270,32 @@ def main():
269270
match = summary_re.search(readme)
270271
if not match:
271272
raise SystemExit(
272-
"ERROR: no '<summary>⚡ See it work...</summary>' line found in README.md — "
273+
"ERROR: no '<details>\\n<summary>⚡ ...</summary>' line found in README.md — "
273274
"update this script's summary_re pattern to match the current heading."
274275
)
275276
readme = readme[:match.end()] + cs_note + readme[match.end():]
276277
print(" ✅ Codespaces + browser notes injected")
277278
else:
278279
print(" (notes already present, skipped)")
279280

281+
# Codespaces-only: open item 1's details block by default — reviewer feedback that
282+
# devs skim code, not prose, and the first prompt-as-code-block should be visible
283+
# without a click on a first-time, one-shot visit. Local README keeps it collapsed
284+
# (every-day use, would be noisy). Scoped to item 1 only — items 2-6 stay collapsed,
285+
# preserving the agenda/outline feel of the numbered list.
286+
item1_re = re.compile(r"<details markdown>\n<summary>[^<]*?1\.[^<]*</summary>")
287+
readme, n = item1_re.subn(
288+
lambda m: m.group(0).replace("<details markdown>", "<details markdown open>", 1),
289+
readme,
290+
count=1,
291+
)
292+
if n == 0:
293+
raise SystemExit(
294+
"ERROR: could not find item 1's <details markdown> block to open by default — "
295+
"update this script's item1_re pattern to match the current heading."
296+
)
297+
print(" ✅ Item 1 details block set to open by default (Codespaces-only)")
298+
280299
readme_path.write_text(readme)
281300

282301
# .vscode/settings.json — global interpreter (Manager root)

README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ This is the start page for the [GenAI-Logic Manager](https://apilogicserver.gith
1010

1111
&nbsp;
1212

13-
## 🤖 AI Assistance - Tell Your AI Assistant
13+
## 🤖 AI Assistance
1414

1515
<details markdown>
16-
<summary>Selecting your AI assistant</summary>
16+
<summary>First select your AI assistant, then paste the prompt below</summary>
1717

1818
&nbsp;
1919

@@ -25,7 +25,7 @@ For more information, see [AI-Enabled Projects](https://apilogicserver.github.io
2525

2626
</details>
2727

28-
Then paste this to your AI assistant:
28+
&nbsp;
2929

3030
```
3131
Please load `.github/.copilot-instructions.md`.
@@ -37,21 +37,21 @@ Please load `.github/.copilot-instructions.md`.
3737
<!-- CODESPACES-INSERT-POINT: create_codespaces_mgr.py injects browser note here — do not rename this heading -->
3838

3939
<details>
40-
<summary>⚡ See it work — build a complete system from a prompt, including logic</summary>
40+
<summary>⚡ Try Prompt → System -- then ask: is this maintainable?</summary>
4141
&nbsp;
4242

4343
You're already running in GitHub Codespaces — a cloud VS Code environment in your browser. Nothing to install. (Use Chrome or Edge — Safari has known compatibility issues with VS Code in the browser.)
4444

4545

46-
&nbsp;
46+
<br>
4747

48-
<details markdown>
49-
<summary>&emsp;&emsp;1. Create — database, API, Admin App and business logic from a prompt</summary>
48+
<details markdown open>
49+
<summary>&emsp;&emsp;1. Create — API, Admin App and business logic from a prompt - existing db</summary>
5050

51-
<br>Say this to your AI assistant (allow 8-10 mins):
51+
<br>Say this to your AI assistant (allow 2-3 mins):
5252

5353
```
54-
Create basic_demo, with customers, orders, items and products.
54+
Create basic_demo from samples/dbs/basic_demo.sqlite (customers, orders, products).
5555
5656
Include a notes field for orders.
5757
@@ -66,13 +66,24 @@ Use case: App Integration
6666
1. Publish the Order to Kafka topic 'order_shipping' if the date_shipped is not None.
6767
```
6868

69-
> Note: the prompt above creates a new database. You *could* use an existing one instead — `create basic_demo from samples/dbs/basic_demo.sqlite` — replacing the first 2 lines above.
69+
<details markdown>
70+
<summary>Or, create with a new database</summary>
71+
72+
<br>The prompt above starts from an *existing* database — the common real-world case (1t does not need to be sqlite). You could create the same system with a *new* database, using a file-based prompt:
73+
74+
```
75+
Create basic_demo from samples/prompts/genai_demo.prompt
76+
```
77+
</details>
78+
79+
&nbsp;
7080

7181
Most code generators produce code you then have to own. This one produces *models* — executable, maintainable:
7282

7383
1. **Data model**`database/models.py`
7484
2. **Full JSONAPI** — Swagger, pagination, optimistic locking (`api/expose_api_models.py` — 52 lines, zero per-table code)
7585
3. **Admin App**`ui/admin/admin.yaml`
86+
4. **Business logic**`logic/logic_discovery/place_order/check_credit.py`
7687

7788
Each small, readable, yours. Plain Python — standard tooling applies.
7889

@@ -164,7 +175,11 @@ Full writeup: [samples/basic_demo_logic_gov/logic/readme_logic](https://apilogic
164175
<details markdown>
165176
<summary>&emsp;&emsp;6. Iterate — ask for a new rule in plain English</summary>
166177

167-
<br>Try: *"Customers should not be able to create new orders if they have unresolved past due letters."* — watch the AI add and explain the new rule.
178+
<br>Try:
179+
```
180+
Customers should not be able to create new orders if they have unresolved past due letters.
181+
```
182+
Since the engine resolves dependencies at load time, adding this rule doesn't touch the 5 you already have — no regeneration, no regression risk. An AI rewriting procedural code from scratch would have to re-touch all of it, with more surface area for a missed path and more tokens spent doing it.
168183

169184
</details>
170185

samples/basic_demo_logic_gov/logic/procedural/credit_service.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
#
1111
# And there's a bug in here. Do you really want to go hunt it down?
1212
#
13+
# The bug: nothing here handles an Order moving to a different Customer, or an
14+
# OrderDetail moving to a different Order — both old and new parents need their
15+
# totals recalculated, and this code only ever touches the current row's parent.
16+
# This is the same re-parenting class of bug documented in
17+
# logic/procedural/declarative-vs-procedural-comparison.md.
18+
#
19+
# The performance issue: calculate_customer_balance() and calculate_order_amount_total()
20+
# re-query and recompute every unshipped order's total from its line items on every call —
21+
# an N+1 query pattern with no caching, even when nothing relevant has changed.
22+
#
1323
# Note: this is a pre-built reference copy, kept here for browsing. Generating
1424
# a project from the prompt yourself will produce an equivalent file, possibly
1525
# under a different project name.

0 commit comments

Comments
 (0)