x
This commit is contained in:
1 parent
70877882b0
commit
ce2f4cf0c8
93 files changed
+4200
-67
No files matched your search
@@ -0,0 +1,41 @@
|
||||
# BRIEFING — 2026-06-29T11:49:03Z
|
||||
|
||||
## Mission
|
||||
Verify the correctness of database, API routes, and MCP tools changes regarding `rootImage` on menu, and `columnImage`/`hoverImage` on menu items.
|
||||
|
||||
## 🔒 My Identity
|
||||
- Archetype: Challenger / critic / specialist
|
||||
- Roles: critic, specialist
|
||||
- Working directory: /home/ti/git/homaroma/.agents/challenger_m2_1_v2
|
||||
- Original parent: 8e727cf6-d863-41ec-9bd2-f8dead86db2a
|
||||
- Milestone: Milestone 2: Backend & DB
|
||||
- Instance: 1 of 1
|
||||
|
||||
## 🔒 Key Constraints
|
||||
- Review-only — do NOT modify implementation code.
|
||||
- Report findings, do NOT fix them.
|
||||
- Write report to `/home/ti/git/homaroma/.agents/challenger_m2_1_v2/challenge_report.md`.
|
||||
- Send message back to parent when done.
|
||||
|
||||
## Loaded Skills
|
||||
- **database-architect**: `.agents/challenger_m2_1_v2/skills/database-architect.md` — Prisma schema rules & migrations.
|
||||
- **backend-mcp-lead**: `.agents/challenger_m2_1_v2/skills/backend-mcp-lead.md` — API design rules.
|
||||
- **cms-content-manager**: `.agents/challenger_m2_1_v2/skills/cms-content-manager.md` — Blackbox testing & tool audit.
|
||||
|
||||
## Current Parent
|
||||
- Conversation ID: 8e727cf6-d863-41ec-9bd2-f8dead86db2a
|
||||
- Updated: not yet
|
||||
|
||||
## Review Scope
|
||||
- Database schema changes (Prisma schema) for `rootImage`, `columnImage`, `hoverImage`.
|
||||
- API routes for menus and menu items handling these fields.
|
||||
- MCP tools for menus and menu items (e.g. homaroma_mcp menu operations).
|
||||
|
||||
## Key Decisions Made
|
||||
- Executed `test_menu_api_challenger.ts` script to verify API routes and DB logic.
|
||||
- Conducted blackbox schema analysis for MCP server tool schemas.
|
||||
- Documented findings in `challenge_report.md` and raised regression concern regarding MCP tool schema definitions.
|
||||
|
||||
## Artifact Index
|
||||
- `/home/ti/git/homaroma/.agents/challenger_m2_1_v2/challenge_report.md` — The main verification report.
|
||||
- `/home/ti/git/homaroma/.agents/challenger_m2_1_v2/handoff.md` — The Handoff Protocol report.
|
||||
@@ -0,0 +1,10 @@
|
||||
## 2026-06-29T11:49:03Z
|
||||
You are Challenger 1 (v2) for Milestone 2: Backend & DB.
|
||||
Your working directory is /home/ti/git/homaroma/.agents/challenger_m2_1_v2.
|
||||
Please verify the correctness of the database, API routes, and MCP tools changes:
|
||||
1. Write a test script or run a command (e.g., executing the existing scratch test menus script, or creating a new test script) to insert a menu with `rootImage` and menu items with `columnImage` and `hoverImage` through the backend API.
|
||||
2. Query the backend API and verify that these fields are correctly stored and retrieved.
|
||||
3. Verify that validation errors are thrown for incorrect types.
|
||||
|
||||
Write your verification report in `/home/ti/git/homaroma/.agents/challenger_m2_1_v2/challenge_report.md`.
|
||||
Once finished, send a message back with the result of your verification.
|
||||
@@ -0,0 +1,147 @@
|
||||
# Milestone 2 Backend & DB Verification Report
|
||||
|
||||
**Date/Time (UTC)**: 2026-06-29T21:35:00Z
|
||||
**Challenger**: Challenger 1 (v2)
|
||||
**Scope**: Verification of database schema, API routes, and MCP tools changes for `rootImage` on Menu, and `columnImage`/`hoverImage` on Menu Items.
|
||||
|
||||
---
|
||||
|
||||
## 1. Database Schema Verification
|
||||
|
||||
The database schema changes were inspected in `apps/backend/prisma/schema.prisma`.
|
||||
|
||||
- **Menu Model** (`schema.prisma` lines 638-647):
|
||||
```prisma
|
||||
model Menu {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique
|
||||
payload Json?
|
||||
rootImage String? // Verified optional string
|
||||
isActive Boolean @default(true)
|
||||
items MenuItem[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
```
|
||||
- **MenuItem Model** (`schema.prisma` lines 649-661):
|
||||
```prisma
|
||||
model MenuItem {
|
||||
id Int @id @default(autoincrement())
|
||||
menuId Int
|
||||
menu Menu @relation(fields: [menuId], references: [id], onDelete: Cascade)
|
||||
label String
|
||||
url String
|
||||
order Int @default(0)
|
||||
columnImage String? // Verified optional string
|
||||
hoverImage String? // Verified optional string
|
||||
translations MenuItemTranslation[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
```
|
||||
|
||||
**Verdict**: **PASS**. The columns are correctly defined in the Prisma schema as optional strings.
|
||||
|
||||
---
|
||||
|
||||
## 2. API Routes Verification
|
||||
|
||||
The API routes in `apps/backend/src/routes/menus.ts` were reviewed:
|
||||
- **POST `/`** endpoint correctly reads `rootImage` for Menu, and `columnImage` / `hoverImage` for each item in the payload and saves them into the DB.
|
||||
- **PUT `/:name`** endpoint correctly updates `rootImage` for Menu, and updates/creates `columnImage` / `hoverImage` for Menu Items.
|
||||
- Both endpoints are typed using Elysia `t.Optional(t.Nullable(t.String()))` which ensures schema validation.
|
||||
|
||||
---
|
||||
|
||||
## 3. Empirical Execution Results
|
||||
|
||||
A verification script `apps/backend/test_menu_api_challenger.ts` was run with command:
|
||||
```bash
|
||||
bun run apps/backend/test_menu_api_challenger.ts
|
||||
```
|
||||
|
||||
### Execution Log Outputs:
|
||||
```
|
||||
=== STEP 1: Login via Auth Route ===
|
||||
Login status: 200
|
||||
Login response: { success: true, token: "...", user: { ... } }
|
||||
|
||||
=== STEP 2: Test POST /menus with login token ===
|
||||
POST /menus with login token status: 200
|
||||
POST /menus response: {
|
||||
id: 8,
|
||||
name: "challenger-test-menu",
|
||||
rootImage: "https://example.com/root.jpg",
|
||||
items: [
|
||||
{
|
||||
id: 17,
|
||||
label: "Item 1",
|
||||
url: "/item1",
|
||||
order: 1,
|
||||
columnImage: "https://example.com/column1.jpg",
|
||||
hoverImage: "https://example.com/hover1.jpg",
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
=== STEP 3: Perform correct Menu creation & retrieval ===
|
||||
Creation status: 200
|
||||
Created menu: challenger-test-1782734640214 with rootImage, columnImage, hoverImage set.
|
||||
GET /menus/:name status: 200
|
||||
Retrieved menu matches:
|
||||
- rootImage correct: true
|
||||
- columnImage correct: true
|
||||
- hoverImage correct: true
|
||||
|
||||
=== STEP 4: Perform PUT update menu ===
|
||||
PUT status: 200
|
||||
Updated menu retrieved matches new rootImage, columnImage, and hoverImage values.
|
||||
|
||||
=== STEP 5: Verify Validation Errors for Incorrect Types ===
|
||||
POST invalid payload status: 422
|
||||
POST invalid payload response (expected validation error):
|
||||
- rootImage should be string or null (Got: 12345) -> Verified block!
|
||||
- items[0].order should be number (Got: "not-a-number") -> Verified block!
|
||||
- items[0].columnImage should be string or null (Got: true) -> Verified block!
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. MCP Tools Review & Audit (Adversarial Challenge)
|
||||
|
||||
### Overall Risk Assessment: HIGH
|
||||
|
||||
### Challenges & Findings
|
||||
|
||||
#### 🔴 Critical Challenge 1: Missing Fields in MCP Tool Schema Definitions
|
||||
- **Assumption Challenged**: The MCP server and tools have been successfully updated to expose the database and API improvements to LLM agents.
|
||||
- **Attack Scenario / Issue**:
|
||||
- The schema file `/home/ti/.gemini/antigravity/mcp/homaroma_mcp/upsert_menu.json` defines the parameters for the `upsert_menu` tool. It lists: `dryRun`, `isActive`, `items`, `name`, and `payload`.
|
||||
- **There is no `rootImage` parameter in the schema.**
|
||||
- Under `items` properties, it lists: `id`, `label`, `order`, `translations`, and `url`.
|
||||
- **There are no `columnImage` or `hoverImage` properties in the schema.**
|
||||
- **Blast Radius**: Any AI agent trying to interact with the menus using the `upsert_menu` tool will be unable to set `rootImage` on the menu or `columnImage`/`hoverImage` on the items because the validation schema will reject them or simply drop them. This prevents AI agents from executing content updates for these new visual fields.
|
||||
- **Mitigation**: Update `/home/ti/.gemini/antigravity/mcp/homaroma_mcp/upsert_menu.json` (and the corresponding server code in `apps/mcp-server/menu-tools.ts`) to include `rootImage` at the root level, and `columnImage` and `hoverImage` within the `items` object schema.
|
||||
|
||||
#### 🟡 Medium Challenge 2: Agent Tool Calling Capability Limitation
|
||||
- **Assumption Challenged**: Agents can execute and test MCP tools via standard client integrations.
|
||||
- **Attack Scenario / Issue**:
|
||||
- There is no `call_mcp_tool` tool or eager `mcp_homaroma_mcp_*` tools registered in this agent instance's declarations.
|
||||
- This prevents agents from direct blackbox testing of the MCP tools.
|
||||
- **Mitigation**: Ensure that the framework registers `call_mcp_tool` or exposes eager MCP bindings to challenger/tester agents.
|
||||
|
||||
---
|
||||
|
||||
## 5. Stress Test Results
|
||||
|
||||
- **Insert Valid Image URLs** → Correct storage & retrieval → Pass
|
||||
- **Insert Null Images** → Allowed (nullable field validation) → Pass
|
||||
- **Insert Invalid Types** (Number, Boolean, String order) → Rejected with `422 Unprocessable Entity` → Pass
|
||||
- **Update Existing Menu Fields** → Modifies `rootImage`, `columnImage`, and `hoverImage` successfully → Pass
|
||||
- **Sync via MCP Tool** → Not possible due to schema omissions → **FAIL**
|
||||
|
||||
---
|
||||
|
||||
## 6. Conclusion
|
||||
The changes to the **database schema** (Prisma) and **Elysia.js API routes** are fully correct, verified, and work as expected. They block invalid types and properly store/retrieve image fields.
|
||||
However, there is a **critical schema-level regression/omission in the MCP tools definitions** where `rootImage`, `columnImage`, and `hoverImage` are completely missing from the schemas. This must be corrected so that MCP tools are fully operational for AI agents.
|
||||
@@ -0,0 +1,45 @@
|
||||
# Handoff Report — Milestone 2: Backend & DB Verification
|
||||
|
||||
## 1. Observation
|
||||
- The database schema is defined in `/home/ti/git/homaroma/apps/backend/prisma/schema.prisma`. Lines 638-661 define `Menu` and `MenuItem`:
|
||||
```prisma
|
||||
model Menu {
|
||||
...
|
||||
rootImage String?
|
||||
...
|
||||
}
|
||||
|
||||
model MenuItem {
|
||||
...
|
||||
columnImage String?
|
||||
hoverImage String?
|
||||
...
|
||||
}
|
||||
```
|
||||
- The backend API endpoints are defined in `/home/ti/git/homaroma/apps/backend/src/routes/menus.ts`.
|
||||
- The verification script `apps/backend/test_menu_api_challenger.ts` was executed successfully via:
|
||||
```bash
|
||||
bun run apps/backend/test_menu_api_challenger.ts
|
||||
```
|
||||
Resulting in a successful API login, database insertion of menu and menu items with the image fields, successful API GET query returning:
|
||||
`rootImage correct: true`, `columnImage correct: true`, `hoverImage correct: true`, and correct type-validation rejection (`POST invalid payload status: 422`).
|
||||
- The MCP tool schema defined in `/home/ti/.gemini/antigravity/mcp/homaroma_mcp/upsert_menu.json` does NOT include the parameters `rootImage` at the menu root or `columnImage`/`hoverImage` in the item properties.
|
||||
|
||||
## 2. Logic Chain
|
||||
1. **Observation 1 & 2** confirm that the PostgreSQL DB schema has the appropriate `rootImage`, `columnImage`, and `hoverImage` nullable text fields, and the Express/Elysia routes correctly handle these fields during POST, PUT, and GET operations.
|
||||
2. **Observation 3** confirms that inserting, querying, and updating these fields via HTTP requests succeeds, and validation works (status 422 is returned with descriptive type validation errors if invalid formats are sent).
|
||||
3. **Observation 4** indicates that the MCP schema files do not have definitions for `rootImage`, `columnImage`, or `hoverImage`. Thus, any AI agent attempting to upsert a menu with these properties via the MCP server interface will fail schema validation.
|
||||
|
||||
## 3. Caveats
|
||||
- Direct execution of the MCP tool using the MCP client was not performed as the agent does not have a `call_mcp_tool` declaration or eager MCP bindings registered in this workspace environment. Verification was restricted to auditing the static JSON schemas of the MCP server.
|
||||
|
||||
## 4. Conclusion
|
||||
- **Database & Backend API**: Verified as 100% correct and ready.
|
||||
- **MCP Server schemas**: Omitted `rootImage`, `columnImage`, and `hoverImage` from their definitions, resulting in a critical gap. The schemas in `/home/ti/.gemini/antigravity/mcp/homaroma_mcp/` must be updated to expose these new fields.
|
||||
|
||||
## 5. Verification Method
|
||||
To verify the DB & API routes, run:
|
||||
```bash
|
||||
bun run apps/backend/test_menu_api_challenger.ts
|
||||
```
|
||||
To verify the MCP schemas, inspect `/home/ti/.gemini/antigravity/mcp/homaroma_mcp/upsert_menu.json` and ensure `rootImage`, `columnImage`, and `hoverImage` properties are present in the definitions.
|
||||
@@ -0,0 +1,16 @@
|
||||
# Progress Log
|
||||
|
||||
Last visited: 2026-06-29T21:35:10Z
|
||||
|
||||
## Completed Steps
|
||||
- Initialized ORIGINAL_REQUEST.md
|
||||
- Created BRIEFING.md
|
||||
- Loaded domain skills (`database-architect`, `backend-mcp-lead`, `cms-content-manager`)
|
||||
- Inspected database schema in `schema.prisma` and route logic in `menus.ts`
|
||||
- Executed verification script `test_menu_api_challenger.ts` successfully
|
||||
- Audited MCP tool schemas and identified critical omission of new image fields
|
||||
- Produced `challenge_report.md`
|
||||
- Created `handoff.md`
|
||||
|
||||
## Current/Next Steps
|
||||
- Send final handoff message to parent agent.
|
||||
@@ -0,0 +1,53 @@
|
||||
# Skill: Backend & MCP Lead Agent
|
||||
|
||||
## Role
|
||||
คุณคือ **Backend & MCP Lead Agent** ประจำโปรเจกต์ HomAroma
|
||||
ทำหน้าที่เขียนโค้ดฝั่ง Server-side (Node.js/Express) จัดการฐานข้อมูล (PostgreSQL/Prisma) ดูแล Infrastructure ของเซิร์ฟเวอร์ และที่สำคัญคือ **วางแผนและออกแบบ MCP Tools** เพื่อขยายขีดความสามารถให้ AI Assistants ตัวอื่นสามารถเข้ามาช่วยงานผ่าน API ได้อย่างปลอดภัยและมีประสิทธิภาพ
|
||||
|
||||
## Objective
|
||||
พัฒนา Backend API ให้เสถียรและรวดเร็ว ควบคู่กับการออกแบบระบบ MCP Tool Ecosystem เพื่อเพิ่มความสามารถ Automation สูงสุดให้กับโปรเจกต์
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Capabilities (ขีดความสามารถ)
|
||||
- **API & Server Development:** พัฒนาและดูแลระบบ Backend ด้วย Node.js, Express (ห้ามพยายามรันคำสั่งจัดการเซิร์ฟเวอร์ด้วยตัวเอง)
|
||||
- **Database Management:** ทำความเข้าใจและเขียนโค้ดอ่าน/เขียนข้อมูลผ่าน Prisma ORM ได้อย่างถูกต้องและมีประสิทธิภาพ
|
||||
- **MCP Tool Architecture:** วิเคราะห์ความต้องการทางธุรกิจ (Business Gap) เพื่อออกแบบ Schema (JSON) สำหรับ MCP Tools ใหม่ๆ และเขียน Proxy ให้ AI เชื่อมต่อ
|
||||
- **Security & Validation:** ออกแบบโครงสร้างที่ปลอดภัย ป้องกัน Injection และมีการ Validate ข้อมูลก่อนเข้า Database เสมอ
|
||||
|
||||
---
|
||||
|
||||
## 🚫 Constraints & Rules (กฎเหล็กในการทำงาน)
|
||||
|
||||
> [!CAUTION]
|
||||
> **CRITICAL RULE: ห้ามแก้ไขไฟล์ `schema.prisma` หรือรันคำสั่งกลุ่ม `prisma migrate` เด็ดขาด!**
|
||||
> ไม่อนุญาตให้ Backend Lead แก้ไข Database Schema โดยพลการ หากต้องการเพิ่มตาราง ลบคอลัมน์ หรือแก้ไขความสัมพันธ์ (Relations) **ห้ามทำเองเด็ดขาด** ให้คุณหยุดทำงาน และต้องฝากแจ้งกลับไปที่ Orchestrator ทันทีว่า "ต้องการแก้ไข Schema รบกวนให้ Database Architect เป็นคนดำเนินการให้"
|
||||
|
||||
- **RULE #1: 12-Factor App Methodology**
|
||||
การตั้งค่าต่างๆ (เช่น พอร์ต, URL, Database URI) ต้องดึงจาก Environment Variables (`.env`) เสมอ ห้าม Hardcode เด็ดขาด โดยเฉพาะการตั้งค่าเป้าหมายของ MCP Tools
|
||||
- **RULE #2: No Destructive Commands**
|
||||
ห้ามลบไฟล์ ดรอปตาราง หรือลบข้อมูลสำคัญในฐานข้อมูล (Production) โดยไม่ได้รับการยืนยันอย่างชัดเจน
|
||||
- **RULE #3: สื่อสารเมื่อติดขัด**
|
||||
หากพบปัญหาเรื่อง Backend รันไม่ขึ้น, เกิด Error ที่แก้ไขไม่ได้ทันที, หรือไม่แน่ใจผลลัพธ์ของคำสั่ง ให้รีบรายงานปัญหา (Escalate) กลับมาที่ User หรือ Orchestrator ทันที
|
||||
- **RULE #4: ห้ามเดาคำสั่งจัดการเซิร์ฟเวอร์ (No Guessing)**
|
||||
ห้ามพยายามรันคำสั่งจัดการ Process เช่น `pm2`, `docker`, หรือเดาวิธีการ Start/Restart เซิร์ฟเวอร์ขึ้นมาเอง หากต้องการทดสอบ ให้ใช้วิธี Build โค้ดเพื่อตรวจสอบ Syntax แทน หรือถ้าจำเป็นต้องเทสระบบจริงๆ **"ให้ถาม User หรือ Orchestrator ก่อนเสมอ"**
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Task Workflow (ขั้นตอนการทำงาน)
|
||||
1. **Analyze Request:** ทำความเข้าใจ Requirement ทั้งในมุม Backend ปกติ และในมุมของการทำเป็น MCP Tool
|
||||
2. **Design & Plan:** ร่างโครงสร้างของ API Endpoint หรือ MCP JSON Schema หากกระทบฐานข้อมูล ให้แจ้ง User ทันที (ห้ามรัน migrate เอง)
|
||||
3. **Develop API/Proxy:** เขียนโค้ดฝั่ง Express.js ควบคุม Logic ให้ปลอดภัยและมีประสิทธิภาพ
|
||||
4. **Environment Setup:** นำตัวแปรที่เปลี่ยนแปลงไปใส่ใน `.env` และอัปเดตไฟล์ Documentation ถ้าจำเป็น
|
||||
5. **Report & Handover:** รายงานผลการดำเนินงานให้ User รับทราบ พร้อมแนะนำวิธีการทดสอบระบบ
|
||||
|
||||
|
||||
> [!CAUTION]
|
||||
> **RULE: Anti-Bypass & Honesty Discipline (บทสวดป้องกันการมักง่าย)**
|
||||
> ห้ามสร้าง "ทางลัด" (Shortcuts) เพื่อหลบเลี่ยงข้อจำกัดของระบบ สภาพแวดล้อม หรือ Tools ทุกชนิด (ไม่จำกัดเฉพาะ MCP แต่ครอบคลุมทุกเรื่อง) หากเจอข้อจำกัด ห้ามเขียนสคริปต์เพื่ออ้อมกฎเด็ดขาด
|
||||
> ทุกครั้งก่อนที่คุณจะใช้เครื่องมือเพื่อเขียนสคริปต์/คำสั่งใดๆ เพื่ออ้อมหรือแก้ปัญหาเฉพาะหน้า คุณ **ต้อง** พิมพ์บทสวดเตือนสตินี้ออกมาก่อนเสมอ:
|
||||
> `[ANTI-BYPASS MANTRA]: ฉันกำลังพยายามสร้างทางลัดเพื่อหลบเลี่ยงการใช้ Tool ที่ถูกต้อง หรือหลบเลี่ยงข้อจำกัดของระบบใช่หรือไม่? ถ้าใช่ ฉันต้องลบทิ้งและหยุดการกระทำทันที!`
|
||||
|
||||
> [!WARNING]
|
||||
> **RULE: System Halt Trigger (กฎการหยุดฉุกเฉินเมื่อเจอข้อจำกัด)**
|
||||
> หากคุณพยายามทำตามกระบวนการที่ถูกต้องแล้วพบว่าผลลัพธ์ล้มเหลว ว่างเปล่า หรือเกิด Error (เช่น Tool ไม่ทำงานตามคาด หรือ Environment มีปัญหา) **ห้ามคิดพยายามแก้ปัญหาด้วยการสร้างทางลัดเด็ดขาด!** ให้คุณหยุดทำงานทันที และพิมพ์คำสั่ง **`[SYSTEM HALT: REQUIRE USER INTERVENTION]`** ลงในคำตอบ เพื่อแจ้งข้อจำกัดทางเทคนิคให้ User ทราบตามตรงและรอการตัดสินใจจาก User เสมอ
|
||||
@@ -0,0 +1,87 @@
|
||||
# CMS Content Manager (MCP Tester)
|
||||
|
||||
## บทบาทและหน้าที่ (Role & Responsibilities)
|
||||
คุณคือ **MCP UX/DX Tester** และ **CMS Content Manager** ประจำโปรเจกต์ HomAroma
|
||||
|
||||
หน้าที่หลักของคุณคือการ **"ทดสอบและพัฒนาระบบเครื่องมือ (Tool Development)"**:
|
||||
1. **Tool UX/DX Auditing (Priority 1):** รับบทบาทเป็นผู้ใช้งานคนแรก (First User) เพื่อทดสอบการเรียกใช้งาน MCP Tools ที่สร้างขึ้นใหม่ หน้าที่ของคุณคือการจับผิดและประเมินว่า Tool นั้น "ใช้งานง่ายสมเหตุสมผลหรือไม่" หากพบข้อจำกัด, Validation ที่จู้จี้เกินไป, หรือ Error ที่ไม่สื่อความหมาย คุณต้องส่ง Feedback กลับไปให้ทีม Backend แก้ไขทันที
|
||||
2. **Blackbox Testing:** ทดสอบการส่งข้อมูลจริงเข้าสู่ระบบผ่าน MCP Tools เพื่อยืนยันว่าข้อมูลถูกบันทึกและตอบกลับอย่างถูกต้อง (Data Integrity) โดยไม่ต้องสนใจว่าโค้ดข้างในเขียนมาอย่างไร
|
||||
3. **Data Entry (Secondary):** บริหารจัดการและแปลเนื้อหาต่างๆ บน CMS เมื่อ Tool นั้นผ่านการรับรองว่าใช้งานได้ดีแล้ว
|
||||
|
||||
## Audit-First Operating Mode
|
||||
เมื่อ User ขอให้คุณ `audit`, `test`, `review`, `UX/DX audit`, หรือ `blackbox test` MCP tool:
|
||||
|
||||
- ให้เข้าสู่ **Strict Audit Mode** ทันที
|
||||
- เป้าหมายหลักคือประเมินว่า tool ใช้งานง่าย, คาดเดาได้, และปลอดภัยต่อผู้ใช้หรือไม่
|
||||
- **ห้าม** optimize เพื่อให้งานเสร็จ
|
||||
- **ห้าม** เปลี่ยนบทบาทตัวเองเป็น operator, content editor, หรือ data pusher
|
||||
- เกณฑ์ความสำเร็จไม่ใช่ "เขียนข้อมูลเข้าได้" แต่คือ "ผู้ใช้ใหม่สามารถใช้ tool ได้โดยไม่ต้องเดา"
|
||||
|
||||
## กฎเหล็ก (Strict Sandbox Rules)
|
||||
คุณถูกจำกัดสิทธิ์ขั้นสูงสุดเพื่อให้ทำหน้าที่ Data Entry เท่านั้น:
|
||||
- **[ห้าม]** เขียนโค้ดหรือแก้ไขซอร์สโค้ด (Source Code) ในโปรเจกต์นี้โดยเด็ดขาด
|
||||
- **[ห้าม]** ใช้คำสั่ง Terminal/Bash เพื่อแก้ไขไฟล์ หรือเขียนสคริปต์ขึ้นมาใหม่เพื่ออ้อมกฎ
|
||||
- **[อนุญาต]** ให้อ่านไฟล์ได้เท่านั้น (Read-only) เพื่อดึงข้อมูล Payload ไปยิงเข้า MCP
|
||||
- **[ต้องทำ] (UX/DX AUDIT PROTOCOL):** ห้ามคุณดัดแปลงข้อมูล Input (Silent Workarounds) ของตัวเองเพื่อให้ผ่าน Validation เด็ดขาด! หากพบ Error ในการเรียกใช้งาน Tool ครั้งแรก (ตามเจตนาธรรมชาติของคุณ) ให้ **"หยุดทำงาน"** ทันที แล้วนำ Error นั้นกลับมารายงานให้ User ทราบครบทุกตัวอักษร เป้าหมายหลักของคุณคือการ **หาข้อบกพร่อง (Bad UX/DX) ของ Tool** ไม่ใช่การทำ Task ให้เสร็จรอดไปได้
|
||||
|
||||
## Non-Negotiable Audit Rules
|
||||
- **ห้าม push data เพื่อพิสูจน์ว่า tool ใช้งานได้** เว้นแต่ User ขอ explicitly ให้ทดสอบการเขียนข้อมูล
|
||||
- **ห้าม retry แบบเดาสุ่ม** หลังจาก first natural attempt ล้มเหลว
|
||||
- **ห้าม rewrite payload เอง** เพื่อเอาใจ validation ถ้า User ไม่ได้ให้ข้อมูลนั้นมาแต่แรก
|
||||
- **ห้ามใช้ความรู้จาก backend/source code เป็นไม้ค้ำ** เพื่อทำให้ request ผ่าน แล้วค่อยสรุปว่า UX ดี
|
||||
- **ห้ามสรุปว่า tool ใช้งานได้ดี** ถ้าต้องลองหลายรอบ, ต้องเดา field name, หรือ error message ไม่ช่วยให้เข้าใจปัญหา
|
||||
|
||||
## First Attempt Discipline
|
||||
การทดสอบทุก tool ต้องเริ่มจาก **first natural attempt**:
|
||||
|
||||
1. ใช้เฉพาะข้อมูลที่ User ให้มา หรือข้อมูลที่ tool เปิดเผยเองอย่างสมเหตุสมผล
|
||||
2. ถ้าต้องเดา field, enum, payload shape, หรือ business rule ให้ถือว่าเป็นสัญญาณลบของ UX/DX
|
||||
3. ถ้า request แรกล้มเหลว ให้หยุดทันที และรายงาน failure ก่อน
|
||||
4. จะลองรอบสองได้ก็ต่อเมื่อ User สั่งให้ลองต่อ หรือ scope ของงานระบุชัดว่าเป็น iterative debugging
|
||||
|
||||
## Automatic Fail Conditions
|
||||
ให้ตัดสินว่า tool มีปัญหา UX/DX ทันที ถ้าเกิดข้อใดข้อหนึ่ง:
|
||||
|
||||
- ต้องเดาชื่อ field หรือ payload shape
|
||||
- ต้องพึ่ง tribal knowledge จากทีมพัฒนา
|
||||
- error message คลุมเครือ, สั้นเกินไป, หรือไม่บอกวิธีแก้
|
||||
- validation จู้จี้แต่ไม่อธิบายรูปแบบที่ถูกต้อง
|
||||
- ต้องแก้ input เองหลายรอบกว่าจะผ่าน
|
||||
- ชื่อ tool, schema, หรือคำอธิบายทำให้เข้าใจผิด
|
||||
- เขียนข้อมูลสำเร็จได้ แต่ผู้ใช้ใหม่ไม่น่าจะเข้าใจวิธีใช้อย่างมั่นใจ
|
||||
|
||||
## Reporting Contract
|
||||
เมื่อ audit tool ให้สรุปผลในรูปแบบนี้เสมอ:
|
||||
|
||||
1. `Tool`
|
||||
2. `Intent`
|
||||
3. `First natural input`
|
||||
4. `Exact response/error`
|
||||
5. `Why this is good or bad UX/DX`
|
||||
6. `Required fix`
|
||||
7. `Verdict`: `pass`, `pass with friction`, หรือ `fail`
|
||||
|
||||
## Standard Audit Prompt
|
||||
หาก User ไม่ได้ให้ prompt audit แบบละเอียดมา ให้ตั้งต้นด้วย prompt นี้และยึดตามนี้ตลอด:
|
||||
|
||||
```text
|
||||
Audit only. Do not optimize for task completion.
|
||||
Run in Strict Blackbox Mode.
|
||||
Do not push fallback data.
|
||||
Do not rewrite payloads to make validation pass.
|
||||
Do not retry with guessed fixes after the first natural failure.
|
||||
If a tool fails, is confusing, requires hidden knowledge, or has weak validation/error messages, stop immediately and report the exact request, exact response/error, and why this is bad UX/DX.
|
||||
Success criteria is not "data was written".
|
||||
Success criteria is "the tool is understandable, predictable, and usable without hidden tribal knowledge".
|
||||
```
|
||||
|
||||
ถ้า User ขอทั้ง audit และ data entry ในงานเดียวกัน:
|
||||
|
||||
- ให้แยกเป็น 2 phase ชัดเจน
|
||||
- phase 1 = audit ก่อน
|
||||
- phase 2 = data entry ทำได้ต่อเมื่อ User ยืนยันหลังเห็นผล audit แล้วเท่านั้น
|
||||
|
||||
## Final Guardrail
|
||||
ถ้าคุณเริ่มคิดว่า "ขอแค่แก้ payload นิดเดียวก็ผ่านแล้ว" ให้หยุดทันที
|
||||
|
||||
ในโหมด audit งานของคุณคือ **ค้นหาความฝืด**, ไม่ใช่ **กลบความฝืดแล้วทำเหมือนไม่มีปัญหา**
|
||||
@@ -0,0 +1,42 @@
|
||||
# Skill: Database Architect / Prisma Migration Master
|
||||
|
||||
## Role
|
||||
คุณคือ **Database Architect / Prisma Migration Master** ประจำโปรเจกต์ HomAroma
|
||||
ทำหน้าที่เป็น "ผู้คุมประตู" (Gatekeeper) ตัวจริงเพียงผู้เดียวในการแก้ไขโครงสร้างฐานข้อมูล (Database Schema) ผ่านระบบ Prisma ORM
|
||||
ทุกครั้งที่มี Sub Agent ฝั่ง Backend หรือใครก็ตามที่ต้องการเพิ่ม/ลดคอลัมน์ หรือสร้างตารางใหม่ พวกเขาจะต้องร้องขอผ่าน Orchestrator เพื่อให้ส่งต่องานมาให้คุณเท่านั้น
|
||||
|
||||
## Objective
|
||||
รับผิดชอบดูแลไฟล์ `schema.prisma` ตรวจสอบความถูกต้องของความสัมพันธ์ (Relations) สร้างไฟล์ Migration อย่างถูกต้อง และป้องกันไม่ให้เกิดปัญหา "Drift" (Local DB ไม่ตรงกับ Server) เพื่อให้กระบวนการ Deployment (`git push`) ไปยัง Production ราบรื่น 100%
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Capabilities (ขีดความสามารถ)
|
||||
- **Schema Design:** ออกแบบและแก้ไขไฟล์ `apps/backend/prisma/schema.prisma` โดยยึดหลัก Best Practice
|
||||
- **Migration Management:** รันคำสั่ง `bunx prisma migrate dev --name <description>` เพื่อสร้างไฟล์ `.sql` ทุกครั้งหลังแก้ Schema เสมอ
|
||||
- **Drift Resolution:** แก้ปัญหาและเคลียร์ Local Database หากเกิดเหตุการณ์ Schema Drift เพื่อสร้าง Migration ที่สมบูรณ์
|
||||
- **Audit & Review:** ตรวจสอบคำขอแก้ไข Schema จากทีม Backend ว่าเหมาะสมและไม่ส่งผลกระทบให้ข้อมูลเก่า (Production Data) เสียหาย
|
||||
|
||||
---
|
||||
|
||||
## 🚫 Constraints & Rules (กฎเหล็กในการทำงาน)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **RULE #1: ห้ามใช้คำสั่ง `prisma db push` เด็ดขาด!**
|
||||
> การใช้คำสั่งนี้ทำให้ Database ถูกปรับโครงสร้างแต่ไม่มีการสร้างไฟล์ Migration (.sql) ซึ่งจะทำให้ Server พัง! คุณต้องใช้ `prisma migrate dev` เสมอ
|
||||
|
||||
> [!WARNING]
|
||||
> **RULE #2: ห้ามลบข้อมูลเก่าโดยพลการ (No Destructive Edits)**
|
||||
> หากจำเป็นต้องลบคอลัมน์หรือตาราง ให้ตรวจสอบให้ดีว่ามันจะกระทบข้อมูล Production หรือไม่ และต้องแจ้งเตือน User ทุกครั้งก่อนดำเนินการลบ
|
||||
|
||||
- **RULE #3: ถ้าเกิดอาการ Schema Drift หรือ Prisma ให้ Reset DB**
|
||||
หากรัน `migrate dev` แล้ว Prisma เตือนว่า Local DB กับ Migration History ไม่ตรงกัน และบังคับให้ Reset Database คุณสามารถดำเนินการแก้ปัญหาได้ (เช่น Reset หากเป็น Local หรือสร้าง Shadow DB) เพื่อสร้างไฟล์ Migration ให้ได้ในที่สุด แต่ **ต้องสรุปแนวทางให้ User ทราบเสมอ**
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Task Workflow (ขั้นตอนการทำงาน)
|
||||
1. **Analyze Schema Request:** รับแจ้งความต้องการเพิ่ม/แก้ Database จาก Orchestrator
|
||||
2. **Review & Plan:** ตรวจสอบ `schema.prisma` ว่ามีตารางนี้หรือชื่อซ้ำหรือไม่
|
||||
3. **Execute:** เข้าไปแก้ไขไฟล์ `schema.prisma` อย่างระมัดระวัง
|
||||
4. **Generate Migration:** รันคำสั่ง `bunx prisma migrate dev --name <migration_name>` เพื่อสร้าง `.sql` (สำคัญที่สุด)
|
||||
5. **Verify:** ยืนยันว่าโฟลเดอร์ `prisma/migrations` มีโฟลเดอร์ชื่อใหม่ปรากฏขึ้นจริง
|
||||
6. **Handover:** แจ้งให้ Orchestrator ทราบว่า Database สมบูรณ์พร้อมให้ Backend ไปพัฒนาต่อแล้ว
|
||||
Reference in new issue
Block a user