# HANDOFF — Brief 5 phút cho session tiếp theo

> **Tiering rule (S40):** giữ **2-3 session gần nhất**. Cũ hơn → `docs/changelog/sessions/`. Full brief history pre-S40 → `docs/_archive/HANDOFF-preS40-fullhistory.md`.

**Last updated:** 2026-06-08 (Session 51 — **P11-C Vehicle+Driver catalogs (Mig 44) + gotcha #57 ext 3 HRM catalog (Mig 45)**, HMW-mode ON product feature, deployed prod Run #371. 7-agent fan-out, reviewer caught Driver FE↔BE required-field contract mismatch → fixed. test 181→186, tables 91→92, bundle admin `Cg9mvltU`/user `YgqDvsqr`. ⚠️ RAG/Qdrant DOWN cả session (file-based fallback). gotcha #57 EXT Master (Department/Supplier/Project, Mig 46) → separate worktree session. Prev S50: Harness 1·2·3 verified-runtime.)

---

## S51 (2026-06-08) — P11-C Vehicle+Driver catalogs + gotcha #57 ext (HMW-mode ON · product feature · deployed prod)

**User: `/session-start` → "P11-C Vehicle+Driver" → "làm đi / chạy luôn cho nhanh". HMW fan-out, ship to prod.**

**Done (commit `30a99aa` → Gitea Run #371 PASS ~4m18s, verified prod):**
- **Mig 44 `AddVehicleAndDriverCatalogs`** — extend HrmConfigs +2 declarative kind (Vehicle/Driver), 2 catalog table filtered-unique day-1. BE Region 5/6 CRUD + Controller +2 route (GET public/write Admin) + MenuKeys +All (auto perm) + DbInitializer idempotent seed. FE KIND_CONFIG +2 ×2 app SHA256 mirror + 4-place (`:kind`-driven, no new route). Tables 91→**92** (sys.tables ground-truth — narrative "93" was +1 drift).
- **Mig 45 `FilterHrmCatalogUniqueIndexesByIsDeleted`** (bundled gotcha #57) — LeaveType+ShiftPattern+**OtPolicy** filtered (3 HRM catalog; OtPolicy missed in "2 catalog" backlog, caught via grep). +5 test-before (181→**186** RED→GREEN).
- **reviewer caught 1 MAJOR** → fixed: Driver FE↔BE required-field mismatch (root = inconsistent em-main brief BE-required vs FE-optional).
- **cicd Run #371:** bundle admin `Cg9mvltU`/user `YgqDvsqr`, 5 idx filtered `([IsDeleted]=(0))` live, smoke 200, /hrm-configs/{vehicles,drivers} wired.

**🔴 NEXT SESSION:**
- **gotcha #57 EXT (worktree session đang chạy):** Department/Supplier/Project (Master) → Mig 46 (3 idx, confirmed-reachable). Merge khi xong — nó tạo Mig 46; main KHÔNG tạo migration nào nữa → no conflict, chỉ cần sequence đúng.
- **RAG/Qdrant DOWN:** restart `rag-infra.ps1 -Action ensure` (AI_INFRA repo) → verify `list_projects`. RAG re-index S42-S51 stale (AI_INFRA op).
- **AI_INFRA-side carry-over:** `/check-email se` pull S50 handshake.
- **🔌 NEW-ALLOC `database-agent`** (AI_INFRA broadcast `2026-06-08-Agent-database-codebase-agents`) — H1 + em main recommend **`/adap-apply`** (STRONG-FIT: DB11 RowVersion fixes S43 lost-update gap; template `AI_INFRA/docs/templates/database-agent.agent.template.md`). 5 caveats: 9th color · EF-pin guard (sql-database-assistant ≠ cover EF Core → pair `ef-core-migration`) · DB7 boundary vs implementer-backend (DB=design/perf/review, impl=author) · executed-file nâc only (runtime PENDING restart+spawn-test) · model:inherit + store_memory-strip. **codebase-agent = SKIP** (investigator covers + csharp-lsp Windows no-op). Needs CLI restart → next session.
- **Product (anh pick):** P11-D ItTicket SLA / P11-E AttendanceReport+OtPolicy multiplier / P11-F MaTicket / Phase 9 Ops.
- **Doc-drift backlog → monthly audit 2026-07-01 (H1 exact coords):** `docs/CLAUDE.md:65` (56→57) + `:70` (91→92 + "Mig 27-42"→"32-45") · `.claude/skills/README.md:20` (ef-core 43→45, S45→S51) · `agents/README.md:157` (plugin "18 enabled"→"18 registered/15 enabled/3 disabled") + `:223` S38-snapshot · **schema-diagram §16+ Mig 32-45 = 14-mig debt (dedicated session)** · cicd-monitor MEMORY essentials label S51-work as "S50" (cosmetic) · STATUS/HANDOFF over-tiering re-tier.

---

## S50 (2026-06-07) — S49 Harness 1·2·3 verified-runtime closeout (HMW-mode ON · infra-finish, no product, CI-skip)

**User: `/session-start` → chọn "Finish S49 infra" → `/session-end`. Đóng trọn 3 phần S49 milestone (verified-runtime).**

**Done (em main + 4 sub spawn — all background per visibility feedback):**
- **(a)** `/session-start` spawned 2 monitor sub (tooling-auditor H1 + harvest-curator H2) → **verified-runtime CONFIRMED**. H1 caught + em main patched 3 freshness drifts (plugin 15→18, skill-index 31→43 mig / 49→57 gotcha, verified-runtime markers). H2 harvest 🟢 clean (0-byte/orphan=0). Test **181 PASS**, RAG 2415.
- **(b)** H2 **wave-mode VERIFIED** — Workflow `hmw.js` wave-run `h2-verify` (Run `wf_b7e4d6ef-787`, 2-agent: investigator-codebase read-only + test-specialist write-direct). **B6 isolation HELD** (git status 6-baseline, sub-MD gitignored, chunk 2415=2415, B4 both-paths). Bonus: gotcha #57 exact coords.
- **(c)** H3 **email send-path VERIFIED** — `/send-email ai_infra` handshake (body-hash `c9656c19…` self-verified MATCH) → `broadcasts/outbox/ai_infra/` + `_index.md` OUTBOUND.
- **session-end §L:** H2 GATE **PASS 5/5** + B5 wave-gom (2 sub-MD → agent-memory). H1 freshness CHỐT (0 new-alloc). §L.a scan: no new RCA (E-005 git-add guard held — staged specific files).

**🔴 NEXT SESSION:**
- **AI_INFRA-side (their step):** `/check-email se` → pull SE handshake → confirm **2-way byte-identical**; optional reply `/send-email se` so SE tests receive-path (`ai_infra/outbox/se/` currently empty).
- **Product (anh pick):** P11-C Vehicle+Driver (Mig 44, recon ready) · **gotcha #57** (coords ready: `LeaveTypeConfiguration.cs:19` + `ShiftPatternConfiguration.cs:19`, template `HrmConfigHolidayTests.cs:180-197`, test-before) · P11-D/E/F · Phase 9 Ops.
- **Cleanup (optional):** wave-folder `.claude/workflows/wave-h2-verify/` harvested → safe to delete (gitignored transient).
- **Doc backlog (low):** STATUS Recently Done + HANDOFF over tiering (re-tier next consolidation) · `agents/README.md:13` ASCII 7→10 lanes (cosmetic).

---

## S49 (2026-06-07) — AI_INFRA Harness 1·2·3 adopt (HMW-mode ON · governance/infra, no product code)

**User: `/ultra-on` + `/adap-apply harness 1·2·3` — BẬT HMW-mode rồi adopt 3 broadcast harness của AI_INFRA.**

**HMW flow:** marker `.claude/hmw-mode.on` tạo (ON) → P2 recon fan-out **4 read-only agent** (3× investigator-codebase gap H1/H2/H3 + 1× investigator-api plugin audit · return-delta · 367K tok ~4m46s) → P3 harvest → em main single-writer WRITE ~25 file → reviewer P4 **PASS all 3**. **Containment post-P2:** git-diff 1 file-write (inv-api self-MEMORY benign) + chunk-count 2414=2414 (0 RAG-write) = defense-in-depth proven.

**Done:**
- **H1 (Self-observability):** roster **8→10** — NEW 2 sub TÁCH BIỆT (anh-mandate H1≠H2 "hay quên+nhầm") `tooling-auditor` (tooling/docs-freshness 4-mặt) + `harvest-curator` (harvest-integrity 5-trục), INFORM-only (4 RAG-read, NO store_memory/Write) + 2 memory seed. Wire `session-start.md` Phase 2.1.1 RE-REPORT + `session-end.md` §L.b 6→7-step. H3 plugin/skill = gộp-vai doc (0 agent mới).
- **H2 (wave-folder isolation):** `hmw.js` wave-mode (subMdPath + tool-aware writeGuard) + `.gitignore` `wave-*/`+`agent-teams/` (B6 **git-check-ignore VERIFIED**) + NEW `.claude/workflows/README.md`. ADD-mode (chỉ workflow DÀI). A agent-team n-a (Windows in-process).
- **H3 (email channel):** NEW `broadcasts/` (outbox/{6 others+all} + inbox/{6 others} + _index + inbox/README + **13 .gitkeep**, committed) + 2 cmd send/check-email (self=`se`, 6 others short-id `{ai_infra,vipix,dyd,namgroup,ashico,bvaau}`) + adap-apply base-path fix `outbox/all/`.
- **3 adap-report** `docs/governance/adap-reports/2026-06-07-Agent-harness-{1,2,3}.md` + reviewer PASS (no blocker; 1 MINOR pre-existing README diagram → fixed). **Test 181 unchanged** (no .cs).

**🔴 S49 NEXT-FIRST — status S50:** restart done. (a) ✅ **DONE S50** — `/session-start` spawned 2 monitor sub, both loaded + ran RE-REPORT clean → verified-runtime CONFIRMED (H1 found 3 freshness drifts → patched; H2 harvest 🟢 clean, 0-byte/orphan none); (b) ✅ **DONE S50** — wave-run `h2-verify` (Run wf_b7e4d6ef-787, 2-agent): B6 isolation HELD (git status 6-baseline, sub-MDs gitignored, chunk 2415 unchanged), B4 both-paths exercised (write-direct + read-only-scribe); B5 harvest → harvest-curator @session-end; (c) ✅ **SE-side DONE S50** — `/send-email ai_infra` handshake written + body-hash self-verified (`c9656c19…`); **AI_INFRA `/check-email se` pull = their step** to complete 2-way byte-identical proof.

**Next product (anh pick):** P11-C Vehicle+Driver (Mig 44, recon ready) · gotcha #57 LeaveType/Shift filtered-unique · P11-D/E/F · Phase 9 Ops.

---

## S48 (2026-06-02) — adap-* verification closure post-restart + FD2 proof + Gov-v2 error-ledger

**User: "làm xong hết đi rồi session-end luôn" — đóng cả 3 adap item post-restart, rồi session-end.**

**Restart confirmed done** (registry có frontend-designer agent + adap-* commands + 8 subs KHÔNG store_memory) → S47 verified-pending nâng cấp. `/adap-apply all-pending` = 0 mới (cả 3 applied S47). `/adap-report all-applied` re-assess + update 3 report (honest §C5/G-015).

**Done (em main solo + 1 FD spawn):**
- **#1 store_memory strip → VERIFIED-runtime** — grep agents `tools:`=0 · registry 0/8 subs. (Caveat giữ: KHÔNG "read-only" — sub vẫn có Bash/Write; containment = defense-in-depth.)
- **#2 frontend-designer FD2 → VERIFIED-RAN** — 🩷 first real spawn (background). Full FD2 loop trên fe-user `/login`: read DS → Vite dev → Playwright shot 375+1440 → viewed PNG → FD4 rubric all-PASS → contrast fix `LoginPage.tsx:56` slate-500→600 → re-shot → build PASS. em main mirror fe-admin (parity). **Rig lessons (FD MEMORY):** (1) Vite-dev `networkidle` never fires → `domcontentloaded`+selector; (2) cold-start dep-optimize >15s → warm-up goto 60s. **Fact: SE = Tailwind v4 CSS-first** (`@theme{}` in index.css, **NO tailwind.config.js**).
- **#3 Gov-v2 delta → CLOSED (executed-file)** — NEW `docs/governance/error-ledger.md` (blameless RCA E-001..E-004 + Active-Guards 2-strike index + §L.a AS-1..AS-9 deterministic-detect + 3-ledger triad map) + §L.b 6-step wired `session-end.md` Phase 1.5 (ran live this session = demo).

**Code shipped:** `fe-{admin,user}/src/pages/LoginPage.tsx` subtitle contrast a11y (slate-500→600, ~7.5:1). Build ×2 PASS 0 TS error. **Test 181 unchanged** (FE-only, no .cs). → code commit deploys → 🟩 cicd-monitor verify bundle rotate.

**⚠️ NEXT SESSION:** (a) ✅ **DONE** — cicd Run #369 PASS, login fix live (admin `DPPTx2Kw`/user `CjoUEsoV`, Mig 43, health 200); no action; (b) §L.b chạy AUTO từ /session-end kế (session này chạy thủ công — command no hot-reload); (c) wire `reviewer` làm FD4 design-gate (quality-ADD, defer); (d) RAG re-index S42-S48 (AI_INFRA op).

**Next product (anh pick):** P11-C Vehicle+Driver (Mig 44, recon ready) · gotcha #57 LeaveType+Shift filtered-unique (test-before) · P11-D/E/F · Phase 9 Ops.

---

## S47 (2026-06-02) — AI_INFRA adap-* adoption channel + 3 broadcasts (infra/governance, no product code)

**Installed federated adoption channel** (AI_INFRA relay): 3 slash-commands `.claude/commands/adap-{apply,report,request}.md` (forked verbatim). Read AI_INFRA `broadcasts/outbox/` read-only (§J2) → apply own repo → `docs/governance/adap-reports/<id>.md`. 3 reports written. 0 agents spawned (em main solo).

**Adopted 3 broadcasts (all nấc executed-file / verified-pending — restart needed, agent/cmd `.md` no hot-reload):**
- **#1 store_memory strip** — removed from ALL 8 subs → **lead (em main) = sole RAG-writer** (em main keeps it). 4 RAG-read retained. Corroborates SE S41 re-bootstrap-loss lesson.
- **#2 frontend-designer (8th agent, pink)** — adopted (user call), forked canonical FD1–FD10 visual-verify floor, tailored SE stack + use-existing-DS + boundary ⟂ implementer-frontend.
- **#3 Gov-v2** — already-applied S44, delta report (gap: no formal error-ledger/§L.b checklist).

**🔴 NEXT SESSION FIRST (anh restart CLI):** 1 restart activates 3 commands + store_memory strip + frontend-designer. Then **spawn-test frontend-designer** small design task → confirm FD2 Playwright loop runs THẬT (upgrades #2 verified-pending → verified). Optional `/adap-report all-applied` re-confirm.

**Follow-ups (non-blocking):** (a) broadcast #3 formal error-ledger/§L.b checklist; (b) wire `reviewer` as FD4 design-gate; (c) RAG re-index S42-S47 (AI_INFRA op).

**Next product (anh pick):** P11-C Vehicle+Driver (Mig 44, recon ready) · gotcha #57 LeaveType/Shift filtered-unique · P11-D/E/F · Phase 9 Ops.

---

## S46 (2026-06-01) — Memory integrity repair (no code, docs-only)

**`/session-start` audit phát hiện S45 close-out để lại 2 file user-memory 0 byte** — `MEMORY.md` (index) + `feedback_background_spawn_visibility.md`. Index rỗng = S46 bootstrap chạy KHÔNG có memory auto-inject (degrade thầm lặng).

**Done (👤 em main solo, no agent spawn):**
- Rebuilt `MEMORY.md` index — 14 entry (8 feedback + 3 project + 2 pattern). Repopulate `feedback_background_spawn_visibility` từ HANDOFF/STATUS S45 ref (marked reconstructed). NEW `feedback_session_end_memory_write_verify`.
- Verified **0 empty `.md`** (`find -size 0` = 0). STATUS count drift "27"→**14** corrected. Test gate re-confirm 181 PASS lúc bootstrap.
- Memory files NGOÀI repo (`~/.claude/.../memory/`) → no git commit cho memory. Chỉ repo docs (STATUS+HANDOFF) = docs-only commit, CI skip.

**Root cause:** S45 session-end flush tạo stub rồi Write body truncate (gotcha #53 — S45 có test-specialist truncate). File 0-byte không báo lỗi + ngoài git-track → trôi tới S46 mới lộ.

**Next S47 (anh pick):** P11-C Vehicle+Driver (Mig 44, recon ready) · gotcha #57 fix LeaveType/Shift filtered-unique · P11-D/E/F · Phase 9 Ops · (optional) add verify-byte-count step vào /session-end skill — đề xuất AI_INFRA per charter v2.

---

## S45 (2026-06-01) — HRM test-gap stabilization + Holiday drift fix (Mig 43)

**2 commit `051b62b` (Tests +27) + `0c5a014` (Mig 43) → push → cicd Run #368 PASS, verified prod. 154→181 test.**

**Done:**
- **Đóng 3 test-gap deferred S35-S38** (stabilize before extend): Gap1 Holiday composite UNIQUE (7) + Gap2 EmployeeSatellite FK-invariant/soft-delete/cascade (10) + Gap3 gotcha #44 authz regression HrmConfigs+Employees (10). 🟪 test-specialist viết (return truncated #53 → 👤 em main verify-on-disk + proxy MEMORY).
- **Mig 43 `FilterHolidayUniqueIndexByIsDeleted`** (👤 em main solo) — Gap1 test lòi bug thật: Holiday DB UNIQUE (Year,Date) unfiltered vs handler `!IsDeleted` → admin xoá + thêm lại ngày lễ cùng date = **500 reachable**. Fix `.HasFilter("[IsDeleted]=0")` (khớp pattern 13×). 🟩 cicd verify filtered index live prod. Table vẫn 91 (index-only), FE bundle unchanged (đúng — BE-only).
- **🟦 P11-C recon sẵn:** Vehicle+Driver = extend HrmConfigs +2 kind declarative (Mig 44), giữ VehicleBooking free-text.

**gotcha #57 NEW:** soft-delete + UNIQUE → MUST `.HasFilter("[IsDeleted]=0")`. ⚠️ **LeaveType.Code + ShiftPattern.Code vẫn unfiltered** (cùng bug, backlog test-before). Process: `feedback_background_spawn_visibility` (foreground spawn im lặng "looks frozen" → đẩy background + report ngay).

**Next S46 (anh pick):** P11-C Vehicle+Driver (Mig 44, recon ready) · gotcha #57 fix LeaveType/Shift filtered-unique · P11-D/E/F · Phase 9 Ops.

---

## S44 (2026-06-01) — Monthly drift audit + AI_INFRA bundle 06-01 (docs-only, 2-way VERIFIED)

**4 commit `ae30f8f` → `5b8736d` → `071c25c` → `5dbcad3`, pushed, tree clean. CI-skip (all .md). 154 test unchanged (no code).**

**Done:**
- **Monthly cadence audit** (cron 2026-06-01, next **2026-07-01**): 🟦 investigator-codebase ground-truth-from-disk scan → 👤 patch **42 count-drift fixes** (`40→42 mig · 84/59/55/47→91 tables · 130/111→154 test · 52/49→56 gotcha`) across CLAUDE.md + docs/CLAUDE.md + ef-core/dependency-audit skills + schema-diagram + database-guide. schema-diagram migration table +Mig 17-42; ef-core history +Mig 27-42; detailed-§ ERD gap (Mig 27-42 modules) flag EXPLICIT → deferred backlog.
- **AI_INFRA bundle 06-01 adopt (full scope):** §A RAG T1/T2 auto · §C 7/7 agent-mem L1 ≤16KB + "25KB"→"~30KB tiered" ×7 · §D **#4 self-report step → /session-end Phase 6.3** (skip #1 have/#3 helper) · §E/§F report+ledger docs/governance. **AI_INFRA RT3 re-verified độc lập → VERIFIED 2-way, ĐÓNG HẲN.**
- **Carry-over S40 ĐÓNG** (`5b8736d`): BROADCAST-2 infra-feedback committed (governance trail) + `.mcp.json` gitignored (machine-path local, no secret).

**Lesson:** "incremented-per-session" counts drift → re-ground từ code monthly (count files). gotchas.md header KHÔNG có self-count → mỗi cite = downstream copy (patch từng chỗ). → memory `feedback_monthly_drift_audit`.

**Còn lại (AI_INFRA-owned, non-blocking):** eval baseline cite 11,922 cũ + SE full re-index (last-index 05-29, S42-S44 stopgap) → AI_INFRA op, batch chung web-MCP migration (ping nếu cần cross_project_search SE tươi sớm).

**Next S45 (anh pick):** product Phase 11 (P11-C Vehicle+Driver / P11-D ItTicket SLA / P11-E AttendanceReport / P11-F MaTicket) · test-gap backlog (Gap1 Holiday UNIQUE 🔴) · Phase 9 Ops.

---

## S43-S38 (older) → session logs

- **S43** (2026-05-30) Phase 11 P11-B LeaveBalance: Mig 42 `AddLeaveBalances` (90→91 tables, UNIQUE composite + FK LeaveTypes Restrict) + trừ phép exactly-once terminal DaDuyet (auto-create từ DaysPerYear, policy cho phép âm + cảnh báo) + FK invariant guard Create/Update + CQRS GetMy/GetUser/Adjust + FE "Số dư phép". 144→154 test, Gitea #367 prod, agents Max 0 bug. → `docs/changelog/sessions/2026-05-30-S42-S43-phase11-p11a-p11b.md`.

- **S42** (2026-05-30) Phase 11 P11-A: Mig 41 WireWorkflowAppsApprovalV2 (4 LevelOpinions + WorkflowAppCodeSequences) + 30 handler 4 module + Max re-review fix 2 FE picker bug. 130→144 test. → `docs/changelog/sessions/2026-05-30-S42-S43-phase11-p11a-p11b.md`.

- **S41** (2026-05-29) RAG corpus cleanup w/ AI_INFRA: `.claude/rag.json` exclude `**/`-anchored fix (gotcha #10) + store_memory reconcile 5/5 (anti-data-loss, at-risk rule) + re-bootstrap 3080→2406 (−674 junk, zero-loss verified). Standing infra backlog → AI_INFRA. Concurrency carry-over (BROADCAST-2 + `.mcp.json`) originated here → **resolved S44** (`5b8736d`). → memory `feedback_store_memory_rebootstrap_protection`.

- **S40** (2026-05-29) init audit 10-mục + doc consolidation (STATUS/HANDOFF 393KB→9KB zero-loss archive) + AI_INFRA bulletin adopt 4/4 (Tiered Memory v1 + /session-start /session-end slash commands LIVE) + RAG MCP recovery (quit+relaunch FRESH). **Concurrency carry-over** (BROADCAST 2 + `.mcp.json`) bắt nguồn đây — vẫn chưa đụng (xem S43).
- **S39** (2026-05-29) infra: Opus 4.8 1M + multi-agent split 4→7 (+investigator/implementer split +test-specialist) + budget +50% + gotcha #54/#55.
- **S38** (2026-05-28) 🎊 Phase 10 COMPLETE 11/11 — Mig 39+40 skeleton combo (Đơn từ/Đặt xe/Ticket/Chấm công/Dashboard NS). ApproveV2+LevelOpinions+LeaveBalance DEFER Phase 11 (→ làm xong S42-S43).

Detail đầy đủ → `docs/changelog/sessions/` + `docs/_archive/HANDOFF-preS40-fullhistory.md`.
