Hubflow ERP × Harness Vibe Code

Hiểu harness để dùng đúng, tinh chỉnh để phù hợp pilot Hub Khánh Xuân

Stage 7 / 13 P0 spec xong · 0 code Pilot: Q4/2026 110 ngày tới deadline
01 · Lineage

Repo này từ đâu ra?

Hiểu nguồn gốc giúp biết cái gì cố định (từ upstream), cái gì custom (của Hubflow ERP).

harness-experimental
huunghiaish
upstream
hubflow-team/hubflow
fork · Hubflow ERP
v9.5 pilot
Hub Khánh Xuân
pilot Q4/2026
🎯 Ý nghĩa thực tế

Harness-vibe-code là template trống (Harness v0, chưa có product code). Zui fork về, lắp Hubflow ERP vào, rồi áp dụng cho pilot thực tế. Tức là repo Hubflow ERP không phải "framework cần install" — nó dự án luôn, có harness đi kèm như công cụ quản lý workflow.

02 · Cấu trúc

Harness là gì, có gì trong đó?

Harness = bộ khung quy trình + template + công cụ để người và AI agent cùng làm dự án. Không phải thư viện, không phải framework code — là "luật chơi".

📋 21 ADR (decisions/)

Quyết định kiến trúc bất biến. Mỗi ADR có lý do + phạm vi. Khi muốn đổi → viết ADR mới supersede, không sửa cũ.

📦 22+ Playbook

Công thức nấu ăn sẵn cho việc lặp lại: discovery interview, gap analysis, build execution, code review, UAT... Mỗi lần gặp vấn đề quen → check playbook trước.

📑 Templates

Mẫu spec-intake, story packet, decision, validation. Không phải viết doc từ đầu — điền vào template.

✅ Verify Gate (hook)

Pre-commit hook cơ khí — block commit nếu TEST_MATRIX có Result: fail. Không bypass bằng --no-verify.

Source-of-truth order (đọc cái nào trước)

Khi vào repo, đọc theo thứ tự này để hiểu nhanh:

  1. STAGE.md — đang ở stage nào (một dòng)
  2. README.md — overview repo
  3. AGENTS.md — quy tắc cho agent + human
  4. docs/HARNESS.md — mô hình hợp tác
  5. docs/WORKFLOW.md — 13 stage delivery map
  6. docs/product/ — hợp đồng sản phẩm (ERD, event catalog, state machine...)
  7. docs/stories/ — story packet (~70+)
  8. docs/decisions/ — tại sao quyết định thế
  9. docs/TEST_MATRIX.md — chứng cứ đã pass chưa
03 · Quy trình

13 stage giao hàng — đang ở đâu?

Mỗi stage có gate riêng, playbook riêng, artifact riêng. Stage nào chưa pass → không nhảy sang stage sau.

1
Lead
d274da7 · 2026-06-01 · greenfield từ CEO Đức + ChatGPT
2
Intake brief
9d39b44 · 2026-06-02 · framing spec là raw input
3A
Discovery interview
cb3734b · 2026-06-02 · 7 rounds × 6 modules, ~45 decisions
3B
Gap analysis
bde4a3c · 2026-06-02 · G1-G8 resolved, G8 corrected (2 builders + Vibecoding)
4
Proposal & SOW
77b7f63 · 2026-06-02 · deadline 30/09, KPI pilot gate
5
Spec + Design intake
a69e575 · 2026-06-02 · 5 P0 docs, APPROVED → Tech Build Ready
6
Visual & Behavioral Modeling
cd3661e · 2026-06-02 · 8-screen concept, state machine, event catalog
7
Story slicing ← ĐANG Ở ĐÂY
in progress · 77 màn P0 specced · 81 packets · chờ detailed prototype
8
Build
pending · mỗi commit cite 1 token (REQ/SC/TC)
9
Code review
pending · score ≥ 7, không dimension nào = 0
10
QA + scenarios
pending · mỗi REQ → 1 row TC trong TEST_MATRIX
11
UAT + signoff
pending · mỗi REQ passed hoặc excluded
12
Release + client update
pending · smoke checklist + release note
13
Handover + maintenance
pending · credentials verified + KT logged
04 · Quy tắc

4 quy tắc sống còn (đừng bypass)

🚫 1. KHÔNG BAO GIỜ bypass Verify Gate

Hook .githooks/harness-verify-gate.sh chạy tự động khi commit. Nó sẽ block commit nếu docs/TEST_MATRIX.mdResult: fail hoặc never-run trên stage-close.

CẤM: git commit --no-verify, git commit -n, git push --no-verify, git config --unset core.hooksPath

ĐÚNG: Fix lỗi thật, hoặc chạy lại verify command rồi ghi Result: pass.

--no-verify chỉ dành cho con người với lý do rõ ràng. Agent không tự ý dùng.

🔗 2. Mỗi commit PHẢI cite token

Token là REQ-xxx (requirement), SC-xxx (scenario), TC-xxx (test case). Commit message phải có token để traceability.

Ví dụ: feat(menu): add menu item list [REQ-M2-001, TC-014]

📌 3. STAGE.md edit CÙNG commit với stage artifact

Đóng stage 7 = sửa STAGE.md History + Snapshot. Sửa này phải land cùng commit với artifact (story packet, ERD addenda, prototype...)

Lý do: tránh drift giữa "nói đã xong" và "thực tế có file".

🧭 4. Read order khi vào repo

Mỗi lần bắt đầu làm việc: STAGE.mdREADMEAGENTS.mdFEATURE_INTAKE.md → spec → docs/product/ARCHITECTURE.md → stories → TEST_MATRIX → decisions → playbooks → WORKFLOW.md.

Đọc sai thứ tự = hiểu sai context = làm sai.

05 · Khác biệt

Hubflow ERP khác upstream chỗ nào?

Upstream harness-experimentaltemplate trống. Hubflow ERP là dự án thật đã lắp Hubflow vào. Đây là những thứ Hubflow ERP có mà upstream không có:

Layer Upstream (harness-experimental) Hubflow ERP (fork)
Product spec Không có (chờ user input) 48 entity ERD, event catalog, state machine, NFR, identity & access
Module Không 6 module (Platform/Menu/Order/Pancake/Migration/Dashboard)
Stories Không ~70-81 story packet, 23 standalone, 6 wave A-D
ADR Một số generic 21 ADR (0015 stack, 0017 system boundary, 0020 design, 0022 AI pattern...)
UI design Không shadcn/ui + Tailwind, agri green hsl(142 64% 38%), light+dark, Inter
Stack Không NestJS + Next.js + PostgreSQL, end-to-end TS, modular monolith
Integration Không Pancake POS (read stock + push orders), Abaha (reference read)
Test data Không Seed data playbook, e2e canonical flow, scenario taxonomy
06 · Tinh chỉnh

Cần tinh chỉnh gì cho phù hợp pilot?

3 blockers hiện tại mà team research nên đề xuất fix:

❌ Blocker 1: bash scripts CRLF

7 file .sh trong repo có line ending Windows. Khi chạy trên Linux/macOS → fail ngay.

# Fix:
find . -name "*.sh" -exec dos2unix {} \;

❌ Blocker 2: hooks chưa enable

git config core.hooksPath chưa set. Tức là Verify Gate vẫn bypass được trên máy chưa config.

git config core.hooksPath .githooks
chmod +x .githooks/*

⚠️ Blocker 3: docs/visuals/ missing

STAGE.md stage 6 nói "concept clickable prototype 8 screens" nhưng thư mục docs/visuals/ không tồn tại. Audit cần:

  • Tạo ADR 0023 ghi nhận sự thiếu
  • Sửa STAGE.md stage 6 row trong cùng commit

Đề xuất tinh chỉnh cho pilot Hub Khánh Xuân

🏗️ Stage 7 → 8 transition

Hiện đang chờ detailed prototype qua claude.ai/design. Cần Zui quyết: làm prototype trước, hay nhảy thẳng Build? Khuyến nghị: làm prototype (giảm rủi ro screen rework).

🤖 AI Suggestion Pattern (FUL-07)

ADR 0022 đã ghi: "AI suggests, human decides, system records". Phase 1 chỉ ship schema ai_suggestion_log + 5 cột trên shortage. Service AiShortageSuggester để Phase 2.

🏘️ Tenant boundary

ADR 0016: mọi table phải có hub_id, mọi query scope theo hub. Pilot = 1 hub (Khánh Xuân) nhưng schema phải multi-tenant từ đầu.

07 · Action

Team dev research cái gì?

📋 Brief từ Neo (Tech Lead)

"Toàn team dev research. e (Mavis) hãy nắm rõ và giải thích cho mọi người hiểu. Tạo 1 HTML page present cho mọi người dễ hiểu."

Research checklist cho mỗi dev

  1. Đọc 3 file gốc: STAGE.md + README.md + AGENTS.md (~30 phút)
  2. Đọc 1 quy trình stage đang ở: docs/STAGE_GOALS.md + playbook stage 7 (~20 phút)
  3. Đọc 3 doc sản phẩm P0: ERD, event catalog, state machine (~1 giờ)
  4. Đọc 5 ADR gần nhất: 0018 (modular monolith), 0019 (event), 0020 (design), 0021 (roadmap), 0022 (AI pattern) (~30 phút)
  5. Đọc 3 story packet mẫu từ wave A để hiểu format (~30 phút)
  6. Đọc TEST_MATRIX để biết proof pattern (~15 phút)
  7. Đề xuất tinh chỉnh: ghi vào docs/HARNESS_BACKLOG.md hoặc tạo PR mới

Đề xuất chia việc research

Người Focus Deliverable
Neo (Tech Lead) Modular monolith boundary (0018) + stack (0015) + system boundary (0017) Doc kiến trúc tổng + module split đề xuất
Lợi Stage 7 story packet + TEST_MATRIX + verify command Template code/test cho 1 story mẫu
Thắng UI design system (0020) + design-guidelines + shadcn tokens Design system contract cho Hubflow ERP
Mavis (AI partner) Pattern tinh chỉnh + HARNESS_BACKLOG + research synthesis PR synthesis tổng (nếu cần)
08 · Tiếp theo

Bước tiếp theo

🎯 Trong tuần này

1. Mỗi dev đọc xong 3 file gốc + checklist research ở trên

2. Họp align 30 phút: chia module + confirm stack + confirm tinh chỉnh

3. Zui quyết: làm detailed prototype trước hay nhảy thẳng Build

🚀 Từ tuần sau

4. Đóng stage 7 → mở stage 8 Build

5. Wave A (6 P0 packet) bắt đầu code

6. Mỗi commit cite token, chạy verify command, update TEST_MATRIX

⚠️ Trước khi code

1. Fix 3 blockers (CRLF, hooksPath, visuals) — không fix thì team khác cũng vấp

2. Confirm runtime stack + module boundary với cả team

3. Đọc và ký cam kết 4 quy tắc sống còn (đặc biệt: KHÔNG bypass Verify Gate)

📚 Tài liệu tham khảo nhanh

  • STAGE.md — đang ở stage nào
  • AGENTS.md — 4 quy tắc + Task Loop 10 bước
  • docs/WORKFLOW.md — 13 stage map
  • docs/HARNESS.md — mô hình hợp tác human × agent
  • docs/FEATURE_INTAKE.md — phân loại tiny/normal/high-risk
  • docs/STAGE_GOALS.md — goal từng stage
  • docs/TEST_MATRIX.md — proof panel
  • docs/HARNESS_BACKLOG.md — đề xuất tinh chỉnh