Adap 6 broadcast (hash MATCH cả 6 indep-recompute) qua 2-workflow Harness-9: - Harness-20 fix-all-structure -> engine §L + dogfood model-note 4-tầng-sweep (incl PERSONA) + 220K→380K neo-supersede + 2-đầu-catch (review bắt 2 DẪN-XUẤT stale-trailer sweep-sót → fixed) - F4 crystallized-backfill = NEW scripts/crystallized-backfill.ps1 (measure-then-fill DRY NO-API; default target=0=OFF owner-authority; calibrated-range; precondition; file-floor=UPPER-BOUND honest) + budget.json config + budget-table wire - F1/F3 already-met (0 hardcoded-violation persona-clean; BƯỚC 0.6 bắt S103=Opus real-metadata) - session-cmd budget-table (Up1) + run-loop 2-tầng (Up2 largely-already-met §L.b(c)) - H16 no-key Applied% = NEW scripts/applied-eval-nokey.ps1 (adversarial-gate fail-closed 3-ca + fault-inject FLIP; mechanism-built numbers-DEFERRED) - memory-hygiene A/B already-met (archive-gate DRY-RUN + governance-detectors 4-layer 1:1); C n/a JS-sandbox no-CLI-launcher - consolidation reference-ack (crystallization≠backfill) engine §L+§M · 6 adap-report + 1 adap-request (#53-garble reasoning-lane mitigation) · send-email fc1e22ac selftest-MATCH · check-email 3 pulled+verified+STAGE-2. 2-workflow: WF1 implement wf_55ef6778-a0d (3 lane schema-CLEAN, selftest exit-0 ×2 + fault-inject teeth) + WF2 review wf_3c5c37cb-aa2 fable-clone (Lane-C PASS returned + Lane-B recover-from-memory PASS; 0-BLOCKING 2-CONCERN-addressed). #53 garble ×3 → em-main recover; investigator AS-10 garble-curation REVERTED (git-backstop). Runtime S103 = Opus (Fable outage lại, per-session flip; H5-fallback revert-free). State GIỮ NGUYÊN: Mig 61 · 89 bảng · 440 test · gotcha 79 · menu 54. 0 prod-code. Co-Authored-By: Claude Opus 4.8 (1M) <noreply@anthropic.com>
16 KiB
description
| description |
|---|
| Đóng session SOLUTION_ERP — flush 10-agent memory + H2 harvest-gate (5-trục) + H1 tooling-chốt, sync MD/RAG, commit + push, eval. Run cuối mỗi session. |
/session-end — Session closeout (FLUSH + WRITE + VERIFY + REPORT + COMMIT + EVAL)
Trigger cuối session. Em main chủ trì, gọi lại sub-agent đã spawn. ⚠️ Harness note (F2 re-verified S100): SendMessage khả dụng lại, NHƯNG flush-flow GIỮ NGUYÊN — agent đã tự update MEMORY khi return (BẮT BUỘC trong agent frontmatter) → em main đọc MEMORY on-disk để synthesize, KHÔNG cần re-spawn/SendMessage chỉ để flush.
📋 BƯỚC 0 — Show command body (visibility, no wait)
Em main PHẢI echo TOÀN BỘ nội dung command body này (đầy đủ Phase 1-6 + sub-section + guard rule) trong response đầu tiên ĐỂ ANH USER ĐỌC LẠI.
Quy trình (KHÔNG wait confirm):
- Em echo full content command (raw markdown, KHÔNG tóm tắt, KHÔNG cắt)
- Em proceed execute Phase 1 → 6 sequential ngay
- Anh user điều chỉnh cuối session nếu cần thay đổi nội dung command (KHÔNG mid-flow interrupt)
Phase 1 — FLUSH (sub-agent memory)
Điều kiện: Chỉ xử lý con đã spawn trong session. KHÔNG spawn mới chỉ để flush (agent đã update MEMORY khi return).
-
Đọc MEMORY.md update của sub-agent đã spawn (Tiered L1 HOT):
- 🟦 investigator-codebase — research findings + audit results + schema/count grounding
- 🟦 investigator-api — external docs/CVE/lib eval + cross-project port + RAG fleet
- 🟨 implementer-backend — BE patterns applied + scope refusals (ACCEPT vs REFUSE)
- 🟧 implementer-frontend — FE mirror SHA256 + Pattern 16-bis 4-place + KIND_CONFIG
- 🟪 test-specialist — test bundle added + coverage gap + spec drift detected
- 🟥 reviewer — anti-patterns observed + Smart Friend catches + claim verification
- 🟢 cicd-monitor — Run verdict + bundle hash rotate + Mig prod + corpus drift
- 🟫 tooling-auditor (monitor H1) — CHỐT tooling/docs-freshness 4-mặt + new-alloc audit (chạy ở §L.b(g))
- ⬜ harvest-curator (monitor H2) — GATE harvest-integrity 5-trục + close-gate run-trace
runs/<id>/(*-synthesis.mdphẳng h10-refine; run cũ S71harvest/) (chạy ở §L.b(d)(f))
-
Synthesize cross-agent learnings → integrate vào:
- User auto-memory
MEMORY.md(index — append entry mới, KHÔNG rewrite) docs/rules.md,docs/architecture.md,docs/gotchas.md,docs/database/,docs/flows/- rules, architecture, gotcha, skill, daily, hand-off (
docs/HANDOFF.md), DB, luồng DB, session log (docs/changelog/sessions/)
- User auto-memory
Phase 1.5 — §L AUTO-MAINTAIN (Gov-v2 keystone — deterministic, KHÔNG daemon)
Artifact home =
docs/governance/error-ledger.md(RCA + Active-Guards index + 3-ledger triad mapping). G-015: đây là step lead chạy ở session-end, KHÔNG phải daemon tự-động-vô-điều-kiện.
§L.a — Deterministic detect (scan action-signature, KHÔNG để AI tự-phán): quét session theo bảng AS-1..AS-9 trong error-ledger. Mỗi hit → 1 RCA entry blameless (5-why + fix + guard). Bug-production = lỗi KÉP → 2 fix (vá code VÀ vá guard/eval-case). List AS mở — gặp class mới thì thêm.
§L.b — 8-step auto-maintain (đủ 8, KHÔNG skip — thiếu = ledger thối). (d)(f) = H2 harvest-curator · (g) = H1 tooling-auditor (2026-06-07 Harness 1) · (h) = User-Mark H-12/13 (S79):
- (a) summary-index += 1 dòng/session vào
STATUS.mdRecently Done (pointer, KHÔNG full-log). - (b) Active-Guards (error-ledger): promote guard 2-strike (episodic→procedural) · mark
verifiednếu held qua session · retire theo net-effect (hại>lợi → gỡ). - (c) chore-flag: agent L1 >~30KB → archive L2 · error-ledger open-entry quá ngưỡng · 0-byte memory check (AS-8) · 🌙 sleep-check (Harness-10b, S72):
last_sleep_atnull hoặc ≥7d (memory-budget.json) → INFORM gợi-ý/sleep-recovery-memory-l2(KHÔNG auto-run) · 🗜️ Harness-11 A/D2 (S75): chạypowershell.exe -ExecutionPolicy Bypass -File scripts/memory-archive-gate.ps1(DRY-RUN) → đề-xuất dồn-archive sub over-cap (A4 hysteresis 0.85 + A5 keep-floor 5 + A6 2-strike) + A7 NO-API L1-eval (pointer-resolve + byte-0-loss). Engine →docs/governance/harness-11-engine.md. DRY-RUN báo kế-hoạch; MOVE thật do em-main (D5 AUTO semantic-null sau khi xem). · 📊 Hot-feed %-print CUỐI phiên (Harness-15-v2 §G.4, S82): in composition Tầng-1 theo %/4-bucket SAU khi đã nạp/tăng trong phiên + Headroom còn-trống so cap role (token_governor.tier1_hotfeed_tokens). Đối-xứngsession-start §2.1.6(đầu phiên). Mục-đích: anh thấy Tầng-1 phình/teo ra sao + còn trống bao nhiêu → quyết chỉnh cap. 🔴 con-số = quyền anh (chủ-dự-án); em-main chỉ báo-%, KHÔNG tự-chỉnh. · 📊 Bảng-số ngân-sách + run-loop 2-tầng (M.B/M.C — Harness-20 adap S103,engine §M): chạypowershell.exe -ExecutionPolicy Bypass -File scripts/crystallized-backfill.ps1→ in BẢNG số THẬT (cap/hotload-bytes/tok-RANGE/headroom/target/backfill, live 0-hardcode) cạnh %-print. Tầng-1 ĐO (deterministic scripts) mỗi end = khối-số tươi (chống "khai-chạy-mà-không-chạy"); Tầng-2 TINH-CHỈNH on-signal (gap-mới/drift-vs-last/orphan-TĂNG/coverage-tụt → cảnh-báo ĐỎ + refine-in-session HOẶC carry-hi-prio nếu đứt-phiên) — KHÔNG nuốt tín-hiệu; weekly full-refine backstop. backfill default 0=OFF (owner). 🟡 M.C largely-already-met (H17-loop + %-print đã có ở dưới), khối-số = formalize. · 🧪 MFE retention opt-in (Harness-16 §H): lệnh kèmeval→ chạyscripts/mfe-eval.ps1cuối-phiên (retention; chênh vs baseline §2.1.6 = rot trong-phiên) → quyết-định 2-ca: thiếu-chỗ→TĂNG budget (anh quyết) / rot→SẮP-XẾP-LẠI (ưu-tiên-giá-trị). READS budget, KHÔNG ghi/auto-tune. · 🔁 H17 loop-REFINE (§I, S95 —harness-11-engine.md §I): lệnh kèmeval→ chạy thêmscripts/memory-selfimprove-audit.ps1(spec-audit CRITERIA+GAP) → áp bảng B1 tín-hiệu→hành-động: floor-rot→reinject-verbatim (ghireinject-ledger.mdCG-1 ≤1/N=3; đo-lại vẫn thiếu→escalate anh KHÔNG tự-reinject-lần-2) · repeat≥2→promote · old+valueless→archive-gate · raw→distill (/sleep-recovery-memory-l2). Phân-loại B3 (build-gap vs floor-rot) TRƯỚC reinject. em-main single-writer D9; loop CHỈ đề-xuất (D6). Light→skip. - (d) flush agent-memory mỗi sub đã spawn session này — spawn-record 4-field
{agent · task · nấc(agreed/executed/verified) · evidence}. (0 sub spawn → "n-a".) → ⬜ harvest-curator (H2) HỖ TRỢ: spawn → propose spawn-record cho mọi sub đã chạy → em main single-writer VERIFY → APPEND (B3 no-overwrite-unverified). - (e) pending-request audit: request anh CHƯA-thực-thi đã log SPECIFICS chưa (KHÔNG placeholder).
- (f) 🌾 harvest-integrity GATE (⬜ harvest-curator H2 — 5-trục, Harness 1+2): verify spawn-record (d) đủ+đúng mọi sub TRƯỚC khi đóng — Coverage (0 silent-miss) · Completeness (đủ 4-field) · Placement (delta đúng
agent-memory/X) · Corruption (moved-not-cut, no-mojibake/shell-baked) · Fidelity-FLAG (nghi bịa/on-behalf → escalate 🟥 reviewer, KHÔNG tự phán). + 🌊 close-gate C5 Layer3 (Harness-10, thay B5 wave-gom): với MỌIruns/<run-id>/của session → VERIFY per-turn harvest đã xong (em-main đã viếtruns/<run-id>/<stage>-synthesis.mdphẳng h10-refine — run cũ S71:harvest/*.md— NGAY sau mỗi fan-out turn = C4 Layer1) + mọiruns/<run-id>/của session có*-synthesis.mdpresent (folder-scan — 🧊 tiêu-chí ledger CLOSE-beat retired H18-B S100). 🔴 IDEMPOTENT — close-gate chỉ VERIFY, KHÔNG re-APPEND (per-turn đã APPEND rồi → re-APPEND = DUPLICATE-HARVEST). 5-trục GATE giữ làm backstop. GATE = run còn*-synthesis.mdvắng (run cũ S71:harvest/rỗng — C8 dual-accept) HOẶC chưa đủ 5-trục thì CHƯA đóng. - (g) 🔌 tooling-freshness CHỐT (🟫 tooling-auditor H1 — Harness 1): spawn → chốt 4-mặt (skill·sub-role·plugin·docs) đổi gì session này + new-alloc audit (skill/plugin MỚI chưa phân-bổ → đề-xuất gán em main + sub phù-hợp vai) + flag doc-drift/roster-lệch/count-stale. Propose → em main APPEND/sửa doc (single-writer). 🔴 G-015: 2 monitor = propose-only, em main VERIFY trước APPEND (Bash residual → KHÔNG "read-only enforced").
- (h) 🔏 User-Mark CHỐT cuối phiên (H-12/13 canonical §P/P7, S79 —
harness-11-engine.md §E): đọc.claude/governance/ACTIVE-MARKS.md→ (i) hiển-thị status-filtered (Active-High/Active hiện · Medium tóm-tắt · Disable ẩn) cho anh đọc lại (đối-xứngsession-start §2.1.4); (ii) nếu session này có quyết-định cấp-governance MỚI (scope-check P6: đổi CANONICAL §-rule/authority) → chạy/user-mark-<cấp>DACI: adjust-gov → double-check → report-trước-đóng-dấu 3-7 tiêu-chí khách-quan (P4) → anh confirm → stampRC-pqhuy1987-dd-mm-yyyy-hh-mm-ss; (iii) supersede/disable mark cũ (P5) → con-trỏ-xuôi + Active-High cần anh-confirm RIÊNG. 🔴 KHÔNG tự đóng dấu / đổi cấp trước khi báo (P4/P8). 0 quyết-định-mới → "n-a, chỉ hiển-thị". - (i) 🎯 H18-D(a) outcome spot-check (S100 —
harness-11-engine.md §J): session governance/review-heavy → chọn 3–5 artifact đã tự-động-qua-cổng trước đó (cicd GO verdict · detector verdict · monitor verdict · adap-report claim) → kiểm-lại TƯƠI bằng ground-truth (tính lại giá-trị đối-chứng · mở định-nghĩa gốc xem claim có thật-cover · đối-chiếu nguyên-văn nguồn). Gấp vào review sẵn có (chi-phí ~0). Sàn-vai trượt-THẬT khỏi nhật-ký → reinject-on-real-miss quareinject-ledger.mdCG-1 (≤1 lần/N=3 phiên, vẫn trượt → escalate anh — REUSE H17 §I B2, KHÔNG sổ mới). Light/hỏi-đáp → skip. (Nấc honest: dogfood n=1 S100 = mẫu hiệu-chỉnh, CHƯA "proven" — caveat 1 broadcast H18.)
Phase 2 — WRITE (update MD/RAG)
2.1 UPDATE/Re-rank MD/RAG đã thay đổi
docs/STATUS.md(In Progress → Recently Done) +docs/HANDOFF.md(tiering: giữ current+2-3 session, archive cũ → session logs perfeedback_status_handoff_tiering)- rules, architecture, gotcha, skill, hand-off, DB, luồng DB, session log
2.2 Skill registry
- Liệt kê 6 skill. Dùng skill khi task khớp (KHÔNG tự suy luận lại)
- Skill staleness audit chỉ chạy theo lịch định kỳ (cron monthly — lịch kế →
docs/STATUS.md, B1) - Phân bổ skill mới phù hợp per agent (README matrix)
2.3 Memory entry mới
- Add memory entry NẾU phát hiện rule/gotcha/decision quan trọng chưa có (vd
feedback_*) - KHÔNG rewrite toàn bộ memory — chỉ append entry mới + update MEMORY.md index 1 dòng
2.4 Quy tắc consolidate MD/RAG (CRITICAL — đọc kỹ) [GENERIC — GIỮ NGUYÊN]
- Thứ 1: Rất quan trọng, đọc kỹ lại quy tắc consolidate đúng cách, những thứ quan trọng KHÔNG đc cắt, chỉ phân tầng cho gọn lại, và xóa double. Phân tầng để các session sau đọc lại đúng chính xác context, không bị over context, rất quan trọng đấy.
- Thứ 2: Nếu MD/RAG không có gì cần điều chỉnh thì KHÔNG cần phải cố gắng điều chỉnh, điều này cũng rất quan trọng.
Phase 3 — VERIFY (test + state)
3.1 Unit test verify
dotnet test SolutionErp.slnx --nologo --verbosity minimal— verify count tăng đúng (vd 130 → 132 nếu thêm 2 test). Update STATUS Recently Done.- Phase 9 UAT mode: feature test-after (có thể skip per chunk), vẫn
npm run build× 2 app. Nếu chỉ docs/infra → ghi "N/A".
3.2 Sub-agent state
- Kiểm tra trạng thái spawn sub-agent (10-agent — 8 product/quality + 2 monitor INFORM-only)
- Task bất kỳ phải phân việc đầy đủ đúng vai trò split boundary (BE→backend, FE→frontend, test→test-specialist)
3.3 RAG + MCP state
- RAG corpus health (chunk count delta,
last_indexed_at). Re-index full = AI_INFRA op (charter v2). - MCP
rag-unifiedstdio launch verify (5 tool) - Re-rank coverage: prompts đã store + đánh dấu re-rank đầy đủ chưa
Phase 4 — REPORT (plan status)
Đặt tên + tô màu cho Plan hiện tại, tiến độ + agent assignment:
Plan cha: [tên]
Plan con: [tên]
Task: [tên] — STATUS: 🟢 done | 🟡 in-progress | ⚪ pending
- 🟦 investigator-codebase — [a] - 🟦 investigator-api — [b]
- 🟨 implementer-backend — [c] - 🟧 implementer-frontend — [d]
- 🟪 test-specialist — [e] - 🟥 reviewer — [f]
- 🟩 cicd-monitor — [g] - 👤 chủ trì — [h]
SOLUTION_ERP report (per-session)
- Tóm tắt việc done + commit SHA + CI Run verdict + bundle hash rotate + plan progress
- (SE KHÔNG copy phần "6 sister report" của AI_INFRA host)
Phase 5 — COMMIT (release)
5.1 Release + commit
- Kiểm tra release, commit task vừa hoàn thành. ⚠️ Update
SolutionErp.slnxnếu có.cs/.csprojmới. - Format:
[CLAUDE] <scope>: <imperative message>+Co-Authored-By: <lead model hiện tại> <noreply@anthropic.com>(hiện = Claude Opus 4.8 — S103 Fable-outage, H5-fallback; đổi theo BƯỚC 0.6 session-start — availability per-session) - Scope:
Contract · PurchaseEvaluation · Budget · Form · Workflow · Supplier · Auth · Admin · Api · App · Domain · Infra · FE-Admin · FE-User · Tests · Docs · CICD · Scripts · Skill
5.2 Push remote
git push origin main→git.baocaogiaoduc.vn/vietreport-admin/solution-erp- Docs-only commit → CI skip per gotcha #41 (paths-ignore
docs/**+**/*.md+.claude/skills/**). Code commit → spawn 🟩 cicd-monitor verify deploy.
Phase 6 — EVAL (chunk + RAG)
6.1 Chunk MD/RAG update
- Cập nhật chunk MD/RAG content mới (Proposal/WorkflowApps/Phase 11...). SE-side:
mcp__rag-unified__store_memorykey facts (stopgap content-gap).
6.2 RAG eval
- ⚠️ Charter v2: RAG eval + full re-index (
bootstrap.py, golden set, recall@5) = AI_INFRA op (cần VOYAGE_API_KEY). SE KHÔNG tự chạy. - SE-side closeout: (a) verify
store_memorychunk retrievable (1search_memoryrerank check); (b) flag drift/staleness lên AI_INFRA nếulast_indexedlag nhiều; (c) báo cáo broadcast nếu adopt infra change.
6.3 INFRA-ADOPTION report (cadence #4 — self-sustaining, AI_INFRA bundle 2026-06-01)
- NẾU session này adopt bất kỳ infra/governance change từ AI_INFRA (RAG fix / session-cmd / hygiene / charter / Gov-v2) → tự-sinh adoption-report §E TRƯỚC khi đóng (KHÔNG cần anh nhắc):
- SERVER-VERIFIABLE (Gitea url): chain N commit sha (origin synced, tree clean)
- Per-§: §A RAG · §B Gov · §C Hygiene (X/7 agent-mem L1 ≤30KB · bloat>50KB=0 — đo byte thật) · §D session-cmd (KHUNG added
<sha>/ skip<đã-có>) · §E evidence (sha list + integrity moved-not-cut) · §F mirror ledger committed<sha> - NẤC: agreed / executed / VERIFIED-self. Caveat by-design: L2 gitignored · CANONICAL-pull = trust.
- Surface report cho anh main relay AI_INFRA (1 lần báo = ACK+executed+evidence). Em main
/session-startkế watch + double-check → cơ chế 2 chiều tự duy trì. - Session KHÔNG adopt infra gì → ghi "N/A (no infra adoption this session)".
Trigger sau Phase 6: Session đóng. Working memory có thể /clear an toàn (persistent memory đã flush + commit + push).