Typed Functions Jev Decisions Offline First

Release — รวม pipeline แล้วตรึงรุ่นCompose the Pipeline and Release Gate

รวมด่านทั้งหมด เก็บรุ่นและหลักฐานรายเคส แล้วใช้ release gate แยกจากการ accept ระหว่าง runtimeCompose the full workflow, preserve audit evidence and distinguish runtime acceptance from the release gate.

By Anirach Mingkhwan AI-Core Functional Workflows 2026 • Post #12 4 min read
Release — รวม pipeline แล้วตรึงรุ่น
ในบทความนี้
  1. เป้าหมายและสิ่งที่ต้องพร้อม
  2. จากโค้ดเดิมสู่ขอบเขตใหม่
  3. ลงมือทีละเจ็ดขั้น
  4. ไฟล์และคำสั่งที่รันได้
  5. ผลที่ควรได้และการตรวจ
  6. ตัวอย่างที่ต้องเข้าใจเมื่อไม่ผ่าน
  7. แบบฝึกในสำเนาทดลอง
  8. ตรวจเมื่อผลไม่ตรง
  9. จุดตรวจถัดไป
  10. แหล่งอ้างอิงและรุ่น
  11. สิ่งที่ควรนำไปใช้ต่อ
In this post
  1. Outcome and prerequisites
  2. Old functions and the new boundary
  3. Seven practical steps
  4. Files and runnable commands
  5. Expected output and verification
  6. A failure to understand
  7. Exercise in a disposable copy
  8. Troubleshooting
  9. Next checkpoint
  10. Sources and version notes
  11. Key takeaways

ตอนที่ 12 จากสิบสอง: รวมด่านทั้งหมด เก็บรุ่นและหลักฐานรายเคส แล้วใช้ release gate แยกจากการ accept ระหว่าง runtime

คำตัดสินและร่างข้อความเริ่มต้นเป็น 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/pipeline.mjs โดย gate state บอกผลต่อชิ้นงานและทางไปต่อ ไม่มี state ใดส่งข้อความหรือแก้บัญชีจริง

จากโค้ดเดิมสู่ขอบเขตใหม่

workflow ที่ประกอบแล้วคือกราฟของ contract ชัด ไม่ใช่ prompt ยาวหนึ่งชิ้น ทุกด่านมีเหตุผลและ state คุมทางไปต่อ pipeline ทำลำดับให้ตรวจได้และคืน audit trail แทนซ่อนความไม่แน่ใจหรืองานที่ล้ม

runtime acceptance gate ตรวจ candidate หนึ่งตัวภายใต้ policy ปัจจุบัน ส่วน release gate ตรวจระบบที่ตรึงกับหลักฐาน held-out การผ่านคำขอเดียวพิสูจน์ไม่ได้ว่าควรปล่อยโมเดล threshold หรือ facts รุ่นใหม่ให้ผู้ใช้ทั้งหมด

แนวคิด AI-Core เดิมของผู้เขียนเน้น contract การจำกัด และการพิสูจน์ แล็บนี้นำมาใช้โดยสิทธิ์ต่อผลจริงยังอยู่ในโค้ด การเรียก Jev ในฟังก์ชันไม่ได้พิสูจน์ว่าระบบใช้งานเป็นอิสระหรือโมเดลขาดไม่ได้ต่อแกนของมัน

ลงมือทีละเจ็ดขั้น

ขั้นที่ 1

อ่าน pipeline จาก input_code ถึง quality_gate ชี้ early return ทุกจุด reject กับ human_review ต้องหยุด revise ต้องมีเพดาน และ accept คืนร่าง ไม่ใช่การกระทำภายนอก

ขั้นที่ 2

รัน V001 จด provider สี่ครั้ง แล้วรัน V008 เทียบ review ตอนจบกับประวัติ revise ทั้งการผ่านและการปฏิเสธที่คุมได้เป็นพฤติกรรมที่ระบบควรมี

ขั้นที่ 3

ดู config/release.json คู่กับ context ของรายงาน ตรึง model ID รุ่นคำถาม policy facts dataset และ hash implementation ป้าย v1 ที่ไม่มี bytes คู่กันไม่ใช่การทดลองที่ทำซ้ำได้

ขั้นที่ 4

รันคำสั่ง release กับ held-out แล้วรับให้ได้ว่า gate อ้างอิง reject เพราะ H010 มี false accept ชุด unit tests สีเขียวไม่พอปล่อย candidate นี้ อย่าผ่อนกฎเพื่อให้เดโมเป็นสีเขียว process ต้องคืน exit code2 ให้ shell/CI ปิดด่านเมื่อไม่ accept ส่วน test suite ตรวจว่าการปฏิเสธนี้ถูกต้อง

ขั้นที่ 5

อ่าน test release gate ที่ใช้ validation กับต้นทุนไม่ครบ validation อนุมัติ release ไม่ได้ และต้นทุนหายอาจต้อง review แม้ false accept ศูนย์ threshold coverage ตัวอย่างเป็นกฎสอน ไม่ใช่มาตรฐานใช้งานจริง ตรวจ metrics ที่จำเป็นก่อนเปรียบเทียบ ค่าขาด ไม่เป็นจำนวนจำกัด ผิดชนิด หรือจำนวน อัตราส่วน และต้นทุนขัดกัน ต้อง reject รายงานแทนปล่อยผ่าน

ขั้นที่ 6

เตรียม checklist ของ shadow run ที่อนุมัติในอนาคต ได้แก่ ป้ายอิสระ กลุ่มภาษา trace timeout/retry เจ้าของ human review เงื่อนไข rollback และไม่มีผลภายนอก repo นี้ไม่มีคำสั่ง deploy หรือเผยแพร่สาธารณะ

ขั้นที่ 7

รัน tests ทั้งหมด เก็บรายงานคู่กับ source hashes แล้วตรวจ companion ในเครื่องพร้อมบทเรียน การเผยแพร่โค้ดกับเว็บไซต์เป็นคนละการกระทำและยังรออนุมัติ

ไฟล์และคำสั่งที่รันได้

เปิด source จริงและอ่าน dependencies ก่อนแก้ นี่คือโค้ดอ้างอิงที่รันได้ ไม่ใช่ SDK ชื่อ AI-Core ที่สมมติขึ้น ลิงก์ชี้ source รุ่นตรึงของ companion สาธารณะใน GitHub

src/pipeline.mjs · tests ของตอนนี้ · แบบฝึกตอนนี้

import {gate,parseDecision} from './contracts.mjs';
import {checkInput} from './input.mjs';
import {authorizeInput,validatePolicy} from './policy.mjs';
import {requestShape} from './questions.mjs';
import {semanticInput,semanticOutput} from './semantic.mjs';
import {checkOutput} from './output.mjs';
import {qualityGate} from './quality.mjs';
import {traditionalReply} from './generation.mjs';
import {CallBudget} from './budget.mjs';
export async function runPipeline(raw,{provider,facts,policy,signal}={}) {
  validatePolicy(policy);
  const budget=new CallBudget(policy,{signal}),history=[];
  const finish=g=>({...g,history,attempts:budget.attempts,calls:budget.used,externalEffects:0});
  const record=(stage,g)=>{history.push({stage,state:g.state,reasons:g.reasons});return g};
  try {
    if(signal?.aborted) return finish(gate('human_review',['cancelled']));
    let g=record('input_code',checkInput(raw));if(g.state!=='accept')return finish(g);
    const input=g.value;
    g=record('authorization',authorizeInput(input));if(g.state!=='accept')return finish(g);
    const judge=async(stage,draft)=>parseDecision(stage,await budget.call(stage,requestShape(stage,input,facts,draft),provider));
    g=record('input_semantic',semanticInput(await judge('input'),policy));if(g.state!=='accept')return finish(g);
    for(let draftNo=1;draftNo<=policy.maxDrafts;draftNo++) {
      const fallback=draftNo>1&&policy.fallback;
      const draft=fallback?traditionalReply(input,facts):await budget.call('generate',{input,facts,draftNo},provider);
      history.push({stage:'generation',draftNo,provider:fallback?'deterministic_template':'mock_generator'});
      g=record('output_code',checkOutput(draft,input,facts));
      if(g.state==='reject')return finish(g);
      if(g.state==='accept') {
        g=record('output_semantic',semanticOutput(await judge('output',draft),policy));
        if(g.state==='reject'||g.state==='human_review')return finish(g);
        if(g.state==='accept') {
          g=record('quality_gate',qualityGate(await judge('quality',draft),policy));
          if(g.state==='accept')return finish(gate('accept',['artifact_accepted_not_authorized_to_send'],draft));
          if(g.state==='human_review'||g.state==='reject')return finish(g);
        }
      }
      if(draftNo===policy.maxDrafts)return finish(gate('human_review',['revision_budget_exhausted']));
    }
  } catch(e) {return finish(gate('human_review',[e.code??'invalid_response_or_provider_failure']))}
  return finish(gate('human_review',['no_terminal_result']));
}

คำสั่งออฟไลน์:

node src/cli.mjs run --case V001
node src/cli.mjs run --case V008
node src/cli.mjs release --split heldout
node --test --test-reporter=spec

ผลที่ควรได้และการตรวจ

V001 accept ชิ้นงาน V008 review หลังสองร่าง และ release ของ held-out reject ด้วย heldout_false_accepts tests ทั้งชุดควรผ่านเพราะตรวจพฤติกรรมเหล่านี้รวมการปฏิเสธ แล็บไม่ได้ implement การ deploy หรือส่งข้อความ คำสั่ง release คืน exit2 ตามที่ตั้งใจ ส่วน test suite ที่ผ่านคืน exit0 และ exit1 หมายถึงคำสั่งหรือ evaluator ผิดพลาด

อ่าน reasons, history และทุก attempt ไม่ดูเพียง label สุดท้าย usage ที่ไม่ทราบต้องยังไม่ทราบ test สีเขียวแสดงเส้นทางโค้ดที่กำหนด ไม่ได้พิสูจน์ความปลอดภัยเชิงความหมายทุกกรณี

ตัวอย่างที่ต้องเข้าใจเมื่อไม่ผ่าน

ทีมอาจสับสนว่า tests ผ่านทั้งหมดเท่ากับพร้อม release ตัวอย่างจงใจให้ semantic fixture ที่อ่อนผ่าน runtime แต่ไม่ผ่านเกณฑ์ release การ reject เป็นผลการเรียนรู้ที่ตั้งใจ ไม่ใช่ test เสียที่ควรลบ

แบบฝึกในสำเนาทดลอง

เขียน release record สำหรับการเปลี่ยน fact สมมติ ระบุสิ่งที่ต้องตรวจซ้ำกับวิธี rollback เก็บ held-out report เดิมไม่แก้ แล้วสร้าง validation รุ่นใหม่ก่อนพิจารณา candidate ถัดไป

ทำตามไฟล์แบบฝึก เก็บต้นฉบับและคืนชุดอ้างอิงก่อนตอนถัดไป อย่าใช้ผล held-out เลือก threshold

ตรวจเมื่อผลไม่ตรง

หากรายงานขาด source hashes หรือ trace รายเคส อย่ารับรอง release จากภาพหน้าจอที่คัดมา ให้รันซ้ำจากรุ่น companion ที่ตรงและเก็บไฟล์หลักฐานฉบับเต็ม exit2 ของเดโม held-out release เป็นผลที่คาด อย่าเปลี่ยนเป็น exit0 เพื่อให้ตัวรันสีเขียว ตัวตรวจคำสั่งต้องเทียบ status ที่คาดอย่างชัดเจน

จุดตรวจถัดไป

ก่อนต่อ ให้บอกคุณสมบัติที่โค้ดตรวจได้แน่นอน คำตัดสินที่ผิดได้ state ที่หยุดงาน และหลักฐานที่ต้องมีก่อนปล่อยรุ่น

← ตอนก่อนหน้า · กลับสารบัญซีรีส์

แหล่งอ้างอิงและรุ่น

เอกสารต้นทางและ companion source

ตรวจเอกสาร TypeSafe วันที่24ตุลาคม2026 บทเรียนตรึงคำขอข้อความที่ jev-1.14.0 และใช้ Choice/Noul ไม่ได้อ้างว่ามีเพียงความสามารถเหล่านี้ โค้ด REST ทางเลือกยังไม่ได้ลอง live ส่วน SDK0.7.0 มีเอกสารแต่แล็บนี้ไม่ต้องติดตั้ง

  1. Existing AI-Core assurance cycle
  2. Jev and coding agents
  3. Models and aliases
  4. Choice
  5. Noul
  6. Confidence statistic
  7. System One REST API
  8. SDK retry policy

สิ่งที่ควรนำไปใช้ต่อ

  • เงื่อนไขแน่นอนและสิทธิ์ยังอยู่ในโค้ด
  • ด่านความหมายและคุณภาพผิดพลาดได้
  • accept, reject, revise และ review มีทางไปต่อคนละแบบ

Part 12 of twelve. Compose the full workflow, preserve audit evidence and distinguish runtime acceptance from the release gate.

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/pipeline.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 composed workflow is a graph of explicit contracts, not one long prompt. Every stage has a reason to exist and a state that controls continuation. The pipeline makes the order reviewable and returns an audit trail instead of hiding uncertain or failed operations.

The runtime acceptance gate evaluates one candidate under the current policy. The release gate evaluates a frozen system against held-out evidence. Passing one request can never establish that a new model, threshold or fact revision should be deployed to all users.

The author’s existing AI-Core context emphasizes contracts, constraints and verification. This lab applies those ideas while leaving authority over effects in code. Merely calling Jev inside a function does not prove that a deployed system is autonomous or that the model is indispensable to its core.

Seven practical steps

Step 1

Read the pipeline from input_code to quality_gate and identify every early return. Make sure reject and human_review stop work, revise is bounded and accept returns a draft artifact rather than an external operation.

Step 2

Run V001 and record its four provider calls. Then run V008 and compare its terminal review and revision history. Success and controlled refusal are both expected system behaviors.

Step 3

Inspect config/release.json alongside report context. Freeze the model ID, question version, policy, facts, dataset and implementation hashes. A label such as v1 without the corresponding bytes is not a reproducible experiment.

Step 4

Run the held-out release command and accept that the reference gate rejects. H010 exposes a false accept, so a green unit-test suite is insufficient to release this candidate. Do not loosen the release rule to make the demo green. Its process exit code is2; shell/CI must treat every non-accept as a failed release gate, while the test suite verifies that this refusal is correct.

Step 5

Read the release-gate tests for a validation split and unknown total cost. Validation cannot approve release; missing cost can require review even when false accepts are zero. The toy coverage threshold is a teaching rule, not a production acceptance standard. Required metrics are validated before comparisons: absent, nonfinite, wrong-typed or contradictory counts, ratios and cost fields reject the report instead of silently passing.

Step 6

Prepare an operational checklist for a future authorized shadow run: independent labels, language slices, timeout/retry traces, human review ownership, rollback trigger and no external effects. This repository implements no deployment or public publishing command.

Step 7

Run the complete test suite and preserve the report with its source hashes. Keep this local companion and tutorial review together. Publishing code and publishing the website are separate actions that remain pending approval.

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/pipeline.mjs · Matching tests · This lesson’s exercise

import {gate,parseDecision} from './contracts.mjs';
import {checkInput} from './input.mjs';
import {authorizeInput,validatePolicy} from './policy.mjs';
import {requestShape} from './questions.mjs';
import {semanticInput,semanticOutput} from './semantic.mjs';
import {checkOutput} from './output.mjs';
import {qualityGate} from './quality.mjs';
import {traditionalReply} from './generation.mjs';
import {CallBudget} from './budget.mjs';
export async function runPipeline(raw,{provider,facts,policy,signal}={}) {
  validatePolicy(policy);
  const budget=new CallBudget(policy,{signal}),history=[];
  const finish=g=>({...g,history,attempts:budget.attempts,calls:budget.used,externalEffects:0});
  const record=(stage,g)=>{history.push({stage,state:g.state,reasons:g.reasons});return g};
  try {
    if(signal?.aborted) return finish(gate('human_review',['cancelled']));
    let g=record('input_code',checkInput(raw));if(g.state!=='accept')return finish(g);
    const input=g.value;
    g=record('authorization',authorizeInput(input));if(g.state!=='accept')return finish(g);
    const judge=async(stage,draft)=>parseDecision(stage,await budget.call(stage,requestShape(stage,input,facts,draft),provider));
    g=record('input_semantic',semanticInput(await judge('input'),policy));if(g.state!=='accept')return finish(g);
    for(let draftNo=1;draftNo<=policy.maxDrafts;draftNo++) {
      const fallback=draftNo>1&&policy.fallback;
      const draft=fallback?traditionalReply(input,facts):await budget.call('generate',{input,facts,draftNo},provider);
      history.push({stage:'generation',draftNo,provider:fallback?'deterministic_template':'mock_generator'});
      g=record('output_code',checkOutput(draft,input,facts));
      if(g.state==='reject')return finish(g);
      if(g.state==='accept') {
        g=record('output_semantic',semanticOutput(await judge('output',draft),policy));
        if(g.state==='reject'||g.state==='human_review')return finish(g);
        if(g.state==='accept') {
          g=record('quality_gate',qualityGate(await judge('quality',draft),policy));
          if(g.state==='accept')return finish(gate('accept',['artifact_accepted_not_authorized_to_send'],draft));
          if(g.state==='human_review'||g.state==='reject')return finish(g);
        }
      }
      if(draftNo===policy.maxDrafts)return finish(gate('human_review',['revision_budget_exhausted']));
    }
  } catch(e) {return finish(gate('human_review',[e.code??'invalid_response_or_provider_failure']))}
  return finish(gate('human_review',['no_terminal_result']));
}

Offline commands:

node src/cli.mjs run --case V001
node src/cli.mjs run --case V008
node src/cli.mjs release --split heldout
node --test --test-reporter=spec

Expected output and verification

V001 accepts an artifact; V008 reviews after two drafts; held-out release rejects with heldout_false_accepts. The full suite should pass because it verifies those specified behaviors, including refusal. No deployment or message sending is implemented by the lab. The release command exits2 by design; the complete passing test suite exits0. Exit1 means a command/evaluator error.

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 team may mistake all tests pass for ready to release. Here a deliberately weak semantic fixture passes its runtime gates but fails the held-out release criterion. The release rejection is the intended educational result, not a broken test to delete.

Exercise in a disposable copy

Draft a release record for a hypothetical fact change. Specify what must be revalidated and how you would roll back. Keep the original held-out report unchanged and create a new validation version before considering another candidate.

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 the report lacks source hashes or per-case traces, do not certify the release from a copied screenshot. Reproduce the run from the exact local companion version and retain the full evidence file. An exit2 from the documented held-out release demo is expected; do not change it to exit0 merely to make a command runner green. Command verification must check the expected status explicitly.

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 · Return to series

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.

  1. Existing AI-Core assurance cycle
  2. Jev and coding agents
  3. Models and aliases
  4. Choice
  5. Noul
  6. Confidence statistic
  7. System One REST API
  8. SDK retry policy

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.
บทปฏิบัติจากซีรีส์ AI-Core Functional Workflows 2026A lab from AI-Core Functional Workflows 2026