Skip to content

Instantly share code, notes, and snippets.

@esz135888
Created May 23, 2026 19:13
Show Gist options
  • Select an option

  • Save esz135888/c60420f4ddab8abdbe19da172d7ff880 to your computer and use it in GitHub Desktop.

Select an option

Save esz135888/c60420f4ddab8abdbe19da172d7ff880 to your computer and use it in GitHub Desktop.
PLS job 4a31ca42 dispatcher preflight contract for customer visit script

Acceptance Tests

Gate 0

  • dispatcher-preflight-contract.html opens.
  • learning-memory.json parses.
  • Required keywords exist: market_context, production_readiness, e2e_verification, people_sync, learning_memory.

Gate 1:Suppress Duplicate Build

Input: registry has usable script/closure/adoption/loop breaker, adoption status none.

Expected: preflight_result=need_adoption_review, dispatch_decision=create_gap_task, no production build job.

Gate 2:Close Ready

Input: registry hit, adoption accept, visit_event_count=2, case_scope=safe.

Expected: preflight_result=close_ready, close action and create proposal module.

Gate 3:Allowed Build

Input: registry_hit_count=0.

Expected: preflight_result=allowed_build, create production build job.

Gate 4:Section Revise

Input: adoption revise with section id and reason.

Expected: create section revision task only, not full script rebuild.

e2e_verification

Verified this round: local files created, JSON parse passes, keywords present, Gist URL must return HTTP 200 and list expected files, upload-files must accept 8 files.

Data Model / API / Sync / Permission Spec

dispatcher_preflight_runs

欄位 型別 說明
id uuid preflight id
project_id uuid project id
action_item_id uuid action item
signal_type text action_overdue
registry_hit_count int usable artifacts count
adoption_review_status enum accept, revise, evidence_gap, none
visit_event_count int valid events
case_scope_status enum safe, blocked, unknown
preflight_result enum close_ready, need_adoption_review, need_visit_evidence, case_blocked, no_response, allowed_build
dispatch_decision enum suppress_build, create_gap_task, close_action, create_build_job
rationale text decision reason
created_at timestamptz run time

API

POST /api/pls/dispatcher/preflight

Rules:

  • Registry has usable script|closure_gate|adoption_ledger|loop_breaker → build suppressed unless revise identifies a section-level change.
  • accept + visit_event_count >= 2 + case_scope_status=safeclose_ready.
  • none before due → need_adoption_review; after due → no_response.
  • accept + visit_event_count < 2need_visit_evidence.
  • case_scope_status=blocked|unknown for external proposal → case_blocked.
  • Only registry_hit_count=0 or explicit section-level revise can return allowed_build.

Permissions / Audit

PLS dispatcher can write preflight runs and suppress build jobs. PLS worker can read preflight result but cannot override it without a decision record. Product owner writes adoption review; customer success writes visit evidence; CEO handles no_response escalation.

Every suppression must keep rationale, created_at, and source_signal_id so future workers know why no production job was created.

Decision Record:Dispatcher Preflight Contract

Background

The same customer visit script overdue action keeps creating new production jobs even after script, closure gate, adoption ledger, and loop breaker artifacts exist.

Options

Option Description Risk
Keep building artifacts Produce another pack each heartbeat Duplicates work and never fixes dispatcher behavior
Rely on learning memory only Tell future worker not to repeat Dispatcher still creates job before worker can decide
Add dispatcher preflight contract Suppress build before job creation unless allowed_build Requires dispatcher adoption

Decision

Choose dispatcher preflight contract.

Why

The failure is upstream of the worker: the job is created before prior artifacts are evaluated. The solution must be a preflight contract with deterministic routing.

Adoption Status

pending_dispatcher_adoption

Owner: PLS dispatcher / project runner routing.

Due: next heartbeat before creating another build for this same action.

Feedback Required If Rejected

  • Which rule incorrectly suppresses build.
  • Which artifact should not count as usable.
  • Which condition should still allow full rebuild.
  • Who can authorize override.
<!doctype html>
<html lang="zh-Hant">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PLS Dispatcher Preflight Contract</title>
<style>
body{margin:0;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:#f8fafc;color:#152033;line-height:1.5}
header{background:#101828;color:white;padding:30px clamp(18px,4vw,50px)}
main{padding:24px clamp(16px,4vw,50px) 46px}
h1,h2,h3{margin:0;line-height:1.2} h1{font-size:clamp(28px,5vw,48px);max-width:1100px} h2{font-size:22px;margin-bottom:12px}
header p{max-width:1050px;color:#d9e2ef;margin:10px 0 0}
.grid{display:grid;grid-template-columns:repeat(12,1fr);gap:14px;margin-bottom:22px}
.card{background:white;border:1px solid #d8e0e8;border-radius:8px;padding:16px;box-shadow:0 1px 2px rgba(16,24,40,.04)}
.span-3{grid-column:span 3}.span-4{grid-column:span 4}.span-6{grid-column:span 6}.span-8{grid-column:span 8}.span-12{grid-column:span 12}
.metric{font-size:31px;font-weight:760;margin:5px 0 2px}.muted{color:#617080}
table{width:100%;border-collapse:collapse}th,td{text-align:left;padding:10px 8px;border-bottom:1px solid #d8e0e8;vertical-align:top}th{font-size:12px;color:#617080;text-transform:uppercase}
.tag{display:inline-flex;min-height:24px;align-items:center;padding:2px 8px;border-radius:999px;border:1px solid currentColor;font-size:12px;font-weight:720;margin:2px 4px 2px 0}.green{color:#0f766e}.blue{color:#1d4ed8}.amber{color:#9a5b00}.red{color:#b42318}
code,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}pre{background:#eef3f7;border-radius:8px;padding:12px;overflow:auto}
.line-draft{white-space:pre-wrap;background:#eff6ff;border:1px solid #bfd7ff;border-radius:8px;padding:14px}
@media(max-width:960px){.span-3,.span-4,.span-6,.span-8{grid-column:span 12}}
</style>
</head>
<body>
<header>
<h1>PLS Dispatcher Preflight Contract</h1>
<p>針對「產出第一版客戶拜訪腳本」反覆被 dispatch 的問題,本成果定義 dispatcher 在建立 production job 前必跑的 preflight contract。它把同一 signal 從「重複生成」改成「查 registry、判 gate、派缺口」。</p>
</header>
<main>
<section class="grid">
<div class="card span-3"><h3>D1</h3><div class="metric green">Preflight</div><p class="muted">同 action 先查 registry。</p></div>
<div class="card span-3"><h3>D7</h3><div class="metric blue">Route</div><p class="muted">缺什麼派什麼。</p></div>
<div class="card span-3"><h3>D14</h3><div class="metric amber">Close</div><p class="muted">達 gate 才關閉並派提案。</p></div>
<div class="card span-3"><h3>D30</h3><div class="metric">Score</div><p class="muted">追 duplicate_job_rate。</p></div>
</section>
<section class="grid">
<div class="card span-8">
<h2>Routing Contract</h2>
<table>
<thead><tr><th>Preflight Result</th><th>條件</th><th>下一步</th></tr></thead>
<tbody>
<tr><td><span class="tag green">close_ready</span></td><td>usable artifact + accept + >=2 visit events + case safe</td><td>不要建 production job;標 close_ready/completed,派 proposal module。</td></tr>
<tr><td><span class="tag amber">need_adoption_review</span></td><td>有 artifacts,但沒有 accept/revise/evidence_gap</td><td>派產品負責人回覆,due 2026-05-25 18:00。</td></tr>
<tr><td><span class="tag blue">need_visit_evidence</span></td><td>accept 但 visit events 少於 2</td><td>派客成補 2 筆 mock/real visit evidence。</td></tr>
<tr><td><span class="tag red">case_blocked</span></td><td>外部案例權限 unknown/blocked</td><td>派案例授權;外部 proposal blocked。</td></tr>
<tr><td><span class="tag red">allowed_build</span></td><td>registry 沒有 usable script/closure/adoption artifact</td><td>才允許建立 production build job。</td></tr>
</tbody>
</table>
</div>
<div class="card span-4">
<h2>Purpose-to-Purpose E2E</h2>
<p>原始目的:客戶拜訪腳本被採用並提升提案轉換。產出物:dispatcher preflight。人採用:PLS 先判 gate;產品/客成只處理缺口。指標改善:duplicate_job_rate 降為 0、close latency 降低、proposal module 更快產出。</p>
</div>
</section>
<section class="grid">
<div class="card span-6">
<h2>Preflight Payload</h2>
<pre>{
"project_id": "b3138a2e-6641-4cc1-859d-8b1d0abf2d3b",
"action_item_id": "76890f66-704c-4bc5-a9e6-e22b0c98da97",
"signal": "action_overdue",
"required_registry_kinds": ["script", "closure_gate", "adoption_ledger", "loop_breaker"],
"gate": {
"adoption_review": "accept|revise|evidence_gap|none",
"visit_event_count": 0,
"case_scope": "safe|blocked|unknown"
}
}</pre>
</div>
<div class="card span-6">
<h2>people_sync</h2>
<div class="line-draft">LINE 草稿:
PLS 已補上客戶拜訪腳本 dispatcher preflight。下一次同一 overdue signal 進來時,不會先建立 production job,而會先查 registry 與 gate:
accept+2證據+case safe → 關閉並派提案;
缺 review → 追產品;
缺 evidence → 追客成;
case blocked → 追授權;
真的沒有 usable artifact 才重建。</div>
</div>
</section>
</main>
</body>
</html>
{
"job_id": "4a31ca42-58ca-45a3-9abb-913dda8d9380",
"project_id": "b3138a2e-6641-4cc1-859d-8b1d0abf2d3b",
"ai_native_project_id": "de53d513-ec69-423b-9de2-7969241d2895",
"learned_at": "2026-05-24T03:18:00+08:00",
"signal": {
"type": "action_overdue",
"summary": "Same customer visit script signal dispatched again after loop breaker",
"root_cause_hypothesis": "Loop breaker artifact exists, but dispatcher lacks preflight suppression before job creation."
},
"recommended_next_check": [
"Did dispatcher run POST /api/pls/dispatcher/preflight before creating job?",
"Did preflight inspect script_delivery_registry?",
"Was preflight_result allowed_build?",
"If not allowed_build, was production job suppressed and gap task created?"
],
"do_not_repeat": [
"Do not create another full production build for this same action if registry has usable artifacts",
"Do not treat missing adoption review as missing script",
"Do not override preflight without decision-record"
],
"next_worker_rules": {
"if_preflight_missing": "create_or_escalate_dispatcher_preflight_task",
"if_preflight_result_need_adoption_review": "dispatch_product_owner_review_only",
"if_preflight_result_need_visit_evidence": "dispatch_customer_success_evidence_only",
"if_preflight_result_close_ready": "close_overdue_and_create_proposal_module",
"if_preflight_result_allowed_build": "allow_one_production_build"
},
"market_context": {
"checked_date": "2026-05-24",
"pattern": "CRM/playbook systems reduce repeat work by embedding usage fields, follow-up tasks, and routing logic before creating more content."
},
"production_readiness": {
"primary_artifact": "dispatcher-preflight-contract.html",
"e2e_verification": "Validate JSON, keywords, Gist URL, uploaded files."
}
}

Dispatcher Preflight Contract Production Brief

場景

「產出第一版客戶拜訪腳本」已連續多輪被 PLS 派成 production job。上一輪已建立 loop breaker,但 dispatcher 仍在沒有 preflight 的情況下建立新 job。本輪產出 implementation-ready preflight contract,讓 PLS 在 dispatch 前先判斷是否應關閉、轉派缺口、或真的重建成果。

30 天路徑

節點 成果 驗收
D1 dispatcher 建立 preflight hook,查 script_delivery_registry。 同 action 先回 preflight_result,不直接 build。
D7 gate-based routing 上線。 duplicate production job = 0,缺口任務有 owner/due。
D14 close_ready 自動關閉 overdue 並派 proposal module。 overdue 不再產生同型 production pack。
D30 scorecard 追 duplicate_job_rate、close_latency、proposal_module_spawned。 用指標迭代 dispatcher。

Purpose-to-Purpose E2E

原始目的:讓客戶拜訪腳本被採用並改善提案轉換。

產出物:preflight contract、routing table、payload schema、acceptance tests、decision record、learning memory。

人採用:PLS dispatcher 先判 gate;墨宇產品負責人只回覆 adoption review;客成補 visit evidence;CEO 只處理 no_response/escalation。

指標改善:減少重複 AI 成本、降低 action close latency、提高 proposal module 產出速度、降低案例越權風險。

market_context

2026-05-24 快速檢查成熟做法:sales playbook 與 CRM adoption 的成熟做法都強調 embedded workflow、saved fields、follow-up tasks、next-best action 與 adoption metrics。本輪把此原則落成 dispatcher preflight:先看既有 artifacts 與採用證據,而非重複生成靜態文件。

Solution Stack

  • 脈絡框架:signal → preflight → registry → gate → route → close/dispatch。
  • 作業流程:claim 前先 evaluate;allowed_build 才建立 production job。
  • 資料/DB 模型:dispatcher_preflight_runsscript_delivery_registryscript_gate_evaluationsdispatch_suppression_events
  • 可操作工具:HTML contract、payload schema、routing table、acceptance tests。
  • 驗收指標:duplicate_job_rate、suppressed_build_count、gap_dispatch_count、close_ready_count。
  • 下一輪升級:將 contract 寫進 PLS dispatcher/worker preclaim hook。

production_readiness

  • Primary artifact:dispatcher-preflight-contract.html
  • Data model:data-model.md
  • E2E tests:acceptance-tests.md
  • Decision record:decision-record.md
  • Learning memory:learning-memory.json

people_sync

PLS 內部同步:同一 action 76890f66-704c-4bc5-a9e6-e22b0c98da97 下次進 dispatcher 時,必須先跑 preflight。若 registry 已有 usable artifacts,禁止再建 production build;依 gate 派 adoption review、visit evidence、case authorization 或 close/proposal module。

learning_memory

本輪推翻的假設:只把 loop breaker 當成果不足以阻止重複派工;必須把 preflight contract 放在 dispatcher 入口。下一輪同 signal 若再出現,先檢查 dispatcher 是否遵守 allowed_build 條件。

Sources

Checked on 2026-05-24.

market_context

Applied Interpretation

The mature pattern is to route based on adoption data before creating more content. This pack makes that route explicit as a dispatcher preflight contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment