OnProud
Module 06 Safe AI Tools & Supervised Writes

Connect & Supervise · Module 06

Safe AI Tools & Supervised Writes

เราจะให้ Agent อ่านและเสนอการเปลี่ยนข้อมูล โดย Rails กับคนยังควบคุมสิทธิ์และความถูกต้องได้อย่างไร?

MCP/tool contractUser scopeStructured writeHuman reviewIdempotencyAudit

Interface boundary

ให้ Agent ใช้ tool ไม่ใช่กุญแจฐานข้อมูล

Rails ยังเป็น system of record และเปิดเฉพาะความสามารถที่มีชื่อ, schema, authentication, user scope, validation และ audit ที่เราตั้งใจ

Start read-only

Read กับ write เป็นคนละระดับความเสี่ยง

เริ่ม tool `search_my_books` ที่ค้นเฉพาะ Vault ของ caller ระบุ input/output/error contract และทดสอบ success, invalid และ cross-user cases

Prompt · Draft one safe read tool
อ่าน PRODUCT_PLAN.md และ ownership rules
เสนอ tool contract สำหรับ search_my_books:
purpose, input schema, output schema, structured errors,
caller identity, user scope, rate boundary, audit event และ tests
ห้ามเปิด raw SQL, database credential หรือ global records
รอ Human approval ก่อนสร้าง

Tool evidence

Tool ผ่านเมื่อเรียกผิดและข้าม user แล้วยังปลอดภัย

ตรวจ schema validation, no-result, unauthorized, rate/error behavior และ audit โดย output ไม่เผยข้อมูลที่ agent ไม่จำเป็นต้องรู้

Write boundary

Agent เสนอ candidate — Rails ตรวจ — คนยืนยัน

ProudVault ใช้ import batch แยกข้อมูลที่ Agent ตีความออกจาก Book/Asset จริง candidate ถูกแก้ reject หรือ merge ได้ก่อน confirm

Agent input Structured candidates Validation Human review Confirm Persist

Candidate model

Staging data ต้องมีสถานะและเจ้าของชัดเจน

Batch/candidate ผูก caller, source, status, errors และ proposed Book match ห้าม candidate กลายเป็น Asset เพียงเพราะ confidence สูง

Idempotency and retry

เรียกซ้ำต้องไม่สร้างข้อมูลซ้ำ

ทุก write request มี idempotency key และ result เดิมเมื่อ retry รวม duplicate detection, partial failure และ transaction boundary

Human review

หน้า review ต้องทำให้คนแก้ใจได้ก่อน confirm

แสดง source, candidate fields, duplicate/conflict, validation error และผลที่จะเกิด พร้อม approve/reject/edit โดยไม่ซ่อน uncertainty

Rails remains the judge

Confirmation ยังต้องผ่าน permission และ validation เดิม

Tool write ห้าม bypass model/service rules, ownership scope หรือ transaction และ audit ต้องบอก caller, tool, batch, decision และผลโดยไม่เก็บ secret

Abuse and failure checks

ทดสอบ prompt ที่ผิด, caller ที่ผิด และการ retry

Red-team invalid schema, cross-user batch, duplicate idempotency key, stale review, partial failure และ audit omission ก่อนเปิดใช้จริง

Transfer to learner projects

เลือกหนึ่ง read และหนึ่ง supervised write ที่เหมาะกับ domain

ผู้เรียนไม่ต้องสร้าง shelf import เหมือน ProudVault แต่ต้องรักษา pattern: bounded tool, structured candidate, Human review, system validation และ audit

Exit Gate

Agent ช่วยได้ แต่ไม่มีสิทธิ์ข้ามเจ้าของระบบ

Demo read tool, rejected cross-user call, reviewed write batch, retry ที่ไม่สร้างซ้ำ และ audit record ที่ย้อนอธิบายได้

Module checkpoint

สิ่งที่ต้องนำออกจากห้อง

MyShelf milestone

Agent ค้นข้อมูลผ่าน scoped tool และเสนอ import batch ที่คนตรวจได้ก่อนบันทึก

Deliverable

Read tool, candidate/review flow, permission tests, idempotency rule และ audit trail

Exit gate

Agent อ่านข้าม user ไม่ได้ และ write ข้าม validation, permission หรือ Human confirmation ไม่ได้

จบ module นี้แล้ว — ไปต่อหรือกลับไปดูภาพรวม

← Module 05 ดูทุก module Module 07 →