ในบทความนี้
In this post
ตอนที่ 9 จากสิบสอง: เขียน acceptance rubric ที่แยกจากความถูก schema และ grounding โดยคะแนนดีไม่ชดเชย hard failure
คำตัดสินและร่างข้อความเริ่มต้นเป็น mock ที่ผู้เขียนกำหนด ไม่ใช่ผล Jev จริง อ่านบทเรียนคู่กับ source, tests และแบบฝึกที่ลิงก์ไปยังรุ่นตรึงใน GitHub
เป้าหมายและสิ่งที่ต้องพร้อม
เตรียม Node22.18 ขึ้นไปกับ terminal clone companion จาก GitHub ตาม README หรือดาวน์โหลด ZIP ฉบับสมบูรณ์ แตกแล้วเข้า ai-core-functional-lab ไม่ต้อง npm install ใช้ API key หรือเรียกโมเดลผ่านเครือข่าย เวลาอ่านไม่รวมการลงมือประมาณ25–45นาที เก็บชุดอ้างอิงหนึ่งชุดและทำแบบฝึกในอีกสำเนา
ดาวน์โหลด companion ZIP · README / แผนบทเรียน
ตอนนี้เน้น src/quality.mjs โดย gate state บอกผลต่อชิ้นงานและทางไปต่อ ไม่มี state ใดส่งข้อความหรือแก้บัญชีจริง
จากโค้ดเดิมสู่ขอบเขตใหม่
คำตอบอาจถูกโครงสร้างและตามหลักฐานแต่ยังไม่ช่วยผู้ใช้ quality gate จึงตรวจ rubric การรับงานแยก ได้แก่ ตอบคำถาม ขั้นตอนใช้ได้ และภาษาเข้าใจง่าย มันอยู่หลัง hard validation กับ grounding ไม่ได้มาแทนสองด่านนั้น
แต่ละข้อใน rubric เป็นประพจน์ yes/no ที่ใช้ Noul ค่าเป็น probability ของ yes ไม่ใช่คะแนนระดับความดีของภาษา โค้ดต้องการให้ทุกข้อผ่านขอบที่เลือก ไม่เอาสองข้อดีมาเฉลี่ยกลบข้อที่อ่อน
gate สี่ state สื่อทางไปต่อไม่เหมือนกัน accept ปล่อยชิ้นงานร่างใน workflow reject หยุดสิ่งต้องห้าม revise ขอแก้แบบจำกัด และ human_review หยุดอัตโนมัติเพราะไม่แน่ใจ ค่าเฉลี่ยที่ดูดีตัดสินทางเหล่านี้แทน policy ไม่ได้
ลงมือทีละเจ็ดขั้น
ขั้นที่ 1
เขียนผลที่ผู้ใช้ต้องการหนึ่งประโยคก่อนตั้ง rubric สำหรับ DeskLite คำตอบที่ใช้ได้ต้องบอกทาง export ตามลำดับ และอธิบายว่าเป็นการดาวน์โหลด ไม่ใช่ส่งไฟล์
ขั้นที่ 2
อ่าน RUBRIC ใน quality.mjs เทียบ key กับ questions.mjs รายการนี้เป็น contract แอป ไม่ใช่ API คุณภาพใหม่ของผู้ขาย ค่าที่ไม่คาดหรือขาดต้องไม่ผ่านโดยค่าเริ่มต้น
ขั้นที่ 3
พิมพ์ quality request ตรวจว่ามีคำถามผู้ใช้ facts และ candidate ปัจจุบัน การดู candidate ลำพังอาจให้รางวัลข้อความลื่นที่ตอบผิดคำถาม
ขั้นที่ 4
รัน quality judgment ของ V008 โดยตรง ค่า plainLanguage ที่กำหนดไว้ต่ำจึงเป็น revise แยกผลด่านนี้จาก state สุดท้ายของ pipeline เมื่อใช้งบซ่อมหมด
ขั้นที่ 5
รัน V008 เต็ม ดู generation สองครั้ง ระบบอ้างอิงจบ human_review หลังสองร่าง ไม่ลองไม่สิ้นสุดจนโมเดลตัวเดิมตอบ yes การตัดสินซ้ำไม่ใช่คะแนนเสียงอิสระ
ขั้นที่ 6
รัน test ขอบตรงกับค่าผิด สามค่า0.8 ผ่าน policy สอนนี้ แต่ค่าขาด ไม่ finite หรือนอกช่วงต้อง review ข้อหนึ่งที่อยู่ช่วงกลางก็ทำให้ review แม้อีกข้ออ่อนอย่างชัดเจน
ขั้นที่ 7
รัน test hardFailure ที่ rubric ทุกตัวเป็น1 ผลยังต้อง reject กฎนี้ป้องกันการตรวจคุณภาพไม่ให้ล้มสิทธิ์ schema หรือเงื่อนไขที่ต่อรองไม่ได้
ไฟล์และคำสั่งที่รันได้
เปิด source จริงและอ่าน dependencies ก่อนแก้ นี่คือโค้ดอ้างอิงที่รันได้ ไม่ใช่ SDK ชื่อ AI-Core ที่สมมติขึ้น ลิงก์ชี้ source รุ่นตรึงของ companion สาธารณะใน GitHub
src/quality.mjs · tests ของตอนนี้ · แบบฝึกตอนนี้
import {gate} from './contracts.mjs';
export const RUBRIC=['answersUser','stepsUsable','plainLanguage'];
export function qualityGate(judgments,policy,{hardFailure=false}={}) {
if(hardFailure) return gate('reject',['hard_constraint_failed']);
if(RUBRIC.some(k=>typeof judgments?.[k]!=='number'||!Number.isFinite(judgments[k])||judgments[k]<0||judgments[k]>1))
return gate('human_review',['quality_schema']);
const low=RUBRIC.filter(k=>judgments[k]<=policy.noMax);
const uncertain=RUBRIC.filter(k=>judgments[k]>policy.noMax&&judgments[k]<policy.yesMin);
if(uncertain.length) return gate('human_review',uncertain.map(k=>'uncertain_'+k));
if(low.length) return gate('revise',low.map(k=>'quality_'+k));
return gate('accept',['all_rubric_checks_pass']);
}
คำสั่งออฟไลน์:
node src/cli.mjs request --stage quality --case V001
node src/cli.mjs judge --stage quality --case V008
node src/cli.mjs run --case V008
node --test --test-reporter=spec test/gates.test.mjs
ผลที่ควรได้และการตรวจ
ด่านตรงของ V008 ให้ revise ส่วน workflow เต็ม review เมื่องบแก้ร่างหมด test ที่มี hard failure ยัง reject แม้ rubric เต็ม นี่คือ policy ที่ทำงานบน mock ไม่ใช่คะแนนคุณภาพที่ calibrate กับผู้ใช้จริง
อ่าน reasons, history และทุก attempt ไม่ดูเพียง label สุดท้าย usage ที่ไม่ทราบต้องยังไม่ทราบ test สีเขียวแสดงเส้นทางโค้ดที่กำหนด ไม่ได้พิสูจน์ความปลอดภัยเชิงความหมายทุกกรณี
ตัวอย่างที่ต้องเข้าใจเมื่อไม่ผ่าน
ค่าเฉลี่ยถ่วงน้ำหนักอาจรับร่างที่อ่านไม่รู้เรื่องเพราะข้อเท็จจริงได้สูง ตัวอย่างนี้ถือแต่ละมิติเป็นเงื่อนไขรับงานแยก หากตั้งใจยอมแลก ต้องระบุและยืนยัน ไม่ซ่อนไว้ในเลขเฉลี่ย
แบบฝึกในสำเนาทดลอง
เพิ่ม criterion ที่สี่ในสำเนา อัปเดต question contract, parser, rubric, fixtures และ tests พร้อมกัน เริ่มจาก test ฟิลด์ที่หายต้องปิดทาง ไม่ใช่เพิ่มแค่ label บนหน้าจอ
ทำตามไฟล์แบบฝึก เก็บต้นฉบับและคืนชุดอ้างอิงก่อนตอนถัดไป อย่าใช้ผล held-out เลือก threshold
ตรวจเมื่อผลไม่ตรง
หาก quality accept เกินคาด ให้ดูว่าตรวจ rubric ทุก key แล้วหรือไม่ การเปรียบเทียบ undefined ใน JavaScript อาจเป็น false เงียบ ๆ แขนง quality_schema กันการขาดข้อมูลไม่ให้ปลอมเป็นผ่าน
จุดตรวจถัดไป
ก่อนต่อ ให้บอกคุณสมบัติที่โค้ดตรวจได้แน่นอน คำตัดสินที่ผิดได้ state ที่หยุดงาน และหลักฐานที่ต้องมีก่อนปล่อยรุ่น
แหล่งอ้างอิงและรุ่น
เอกสารต้นทางและ companion source
ตรวจเอกสาร TypeSafe วันที่24ตุลาคม2026 บทเรียนตรึงคำขอข้อความที่ jev-1.14.0 และใช้ Choice/Noul ไม่ได้อ้างว่ามีเพียงความสามารถเหล่านี้ โค้ด REST ทางเลือกยังไม่ได้ลอง live ส่วน SDK0.7.0 มีเอกสารแต่แล็บนี้ไม่ต้องติดตั้ง
สิ่งที่ควรนำไปใช้ต่อ
- เงื่อนไขแน่นอนและสิทธิ์ยังอยู่ในโค้ด
- ด่านความหมายและคุณภาพผิดพลาดได้
- accept, reject, revise และ review มีทางไปต่อคนละแบบ
Part 9 of twelve. Separate usefulness and clarity from schema and grounding; no strong rubric value cancels a hard constraint.
Default decisions and draft text are authored mocks, not live Jev results. Use the tutorial with the matching companion code, tests and exercise linked to a fixed GitHub version.
Outcome and prerequisites
Use Node22.18+ and a terminal. Clone the GitHub companion using its README, or download the complete ZIP, extract it and enter ai-core-functional-lab. No npm install, API key or network inference is needed. The reading-time label excludes about25–45 minutes of hands-on work. Keep one reference copy and make exercises in another.
Download companion ZIP · README / lesson map
This part focuses on src/quality.mjs. Expected gate states describe content and continuation; no state sends a message or changes a real account.
Old functions and the new boundary
A response can be well-formed and grounded yet fail to help the user. The quality gate therefore checks a separate acceptance rubric: answer the question, provide usable steps and use clear language. It comes after hard validation and grounding rather than replacing them.
Each rubric item is a yes/no proposition evaluated with Noul. The value is probability of yes, not a score measuring how good the prose is. The code requires every item to meet the chosen threshold; it does not average a weak item away with two strong ones.
Four gate states communicate different next steps. Accept releases a draft artifact inside the workflow, reject stops forbidden content, revise requests bounded editing, and human_review stops automation for uncertainty. A good-looking average cannot decide these paths on behalf of application policy.
Seven practical steps
Step 1
Write one sentence describing the user’s desired outcome before defining the rubric. For DeskLite, a useful answer gives the export path in order and explains that it downloads rather than sends the file.
Step 2
Read RUBRIC in quality.mjs and match each key to questions.mjs. The key list is an application contract, not a new vendor quality API. Unexpected or missing data must not pass by default.
Step 3
Print the quality request and verify it contains the user question, trusted facts and current candidate. Evaluating a candidate in isolation can reward fluent text that answers the wrong question.
Step 4
Run the direct V008 quality judgment. The authored plainLanguage value is low, so the state is revise. Keep that local gate result distinct from the final pipeline state after the repair budget runs out.
Step 5
Run full V008 and inspect both generations. The reference stops with human_review after two drafts rather than trying indefinitely until the same model says yes. Repeated judgments are not independent votes.
Step 6
Run exact-boundary and invalid-value tests. All three0.8 values pass this teaching policy; a missing, nonfinite or out-of-range value reviews. One middle-band item also reviews even if another item is clearly weak.
Step 7
Run the hardFailure test with every rubric item equal to1. Reject must still win. This is the rule that prevents quality evaluation from overruling authorization, schema or other nonnegotiable constraints.
Files and runnable commands
Open the exact source and read its dependencies before editing. This is runnable reference code, not a fictional AI-Core SDK. The source links point to a fixed version of the public GitHub companion.
src/quality.mjs · Matching tests · This lesson’s exercise
import {gate} from './contracts.mjs';
export const RUBRIC=['answersUser','stepsUsable','plainLanguage'];
export function qualityGate(judgments,policy,{hardFailure=false}={}) {
if(hardFailure) return gate('reject',['hard_constraint_failed']);
if(RUBRIC.some(k=>typeof judgments?.[k]!=='number'||!Number.isFinite(judgments[k])||judgments[k]<0||judgments[k]>1))
return gate('human_review',['quality_schema']);
const low=RUBRIC.filter(k=>judgments[k]<=policy.noMax);
const uncertain=RUBRIC.filter(k=>judgments[k]>policy.noMax&&judgments[k]<policy.yesMin);
if(uncertain.length) return gate('human_review',uncertain.map(k=>'uncertain_'+k));
if(low.length) return gate('revise',low.map(k=>'quality_'+k));
return gate('accept',['all_rubric_checks_pass']);
}
Offline commands:
node src/cli.mjs request --stage quality --case V001
node src/cli.mjs judge --stage quality --case V008
node src/cli.mjs run --case V008
node --test --test-reporter=spec test/gates.test.mjs
Expected output and verification
The direct V008 gate revises; the full workflow reviews after exhausting bounded revisions. The test with a hard failure rejects despite perfect rubric values. These are policy behaviors over mock judgments, not a calibrated quality score for real users.
Inspect reasons, history and every attempt rather than only the final label. Unknown usage must remain unknown. A green test demonstrates the specified code path, not universal semantic safety.
A failure to understand
A weighted mean can accept a draft whose clarity is unusable because factuality is high. In this example the dimensions are separate acceptance conditions. If you intentionally permit tradeoffs, specify and validate them rather than hiding them in arithmetic.
Exercise in a disposable copy
Add a fourth criterion in a disposable copy. Update the question contract, parser, rubric, fixtures and tests together. First make a missing-answer test fail closed; do not merely append a UI label.
Follow the matching exercise file, retain the original and restore the reference before the next chapter. Do not use held-out results to choose a threshold.
Troubleshooting
If quality unexpectedly accepts, inspect whether every rubric key was validated. Undefined comparisons in JavaScript can quietly evaluate false; the explicit quality_schema branch prevents absence from masquerading as success.
Next checkpoint
Before continuing, name the property that code checks exactly, the judgment that may be wrong, the state that stops work and the evidence needed before release.
← Previous lesson · Next lesson →
Sources and version notes
Primary documentation and companion source
Official TypeSafe docs checked2026-10-24. This curriculum pins text requests to jev-1.14.0 and uses Choice/Noul; it does not claim those exhaust Jev’s capabilities. Optional REST code is untested live. SDK0.7.0 is documented but unnecessary for this no-install lab.
Key takeaways
- Deterministic constraints and authorization stay in code.
- Semantic guards and quality judgments are fallible.
- Accept, reject, revise and review have distinct continuation rules.