Files
solution-erp/.claude/agent-memory/cicd-monitor/MEMORY.md
2026-08-01 10:38:46 +07:00

17 KiB
Raw Blame History

CI/CD Monitor Agent — Persistent Memory

  • S166 (08-01) 88e7ecf K4a+K4b sidebar 8-nhóm × 6-leaf + nối ?group= (0-mig) — PASS 7/7 (#438 6m23s · gate 621=45+576 · Mig GIỮ 71 · menu 151→200 · perm 1584→2221). 🔑 PHỦ 2 RUN 1 LƯỢT ⇒ delta KHÉP KÍN: #437 F-1 = 614 (Infra +0) ⇒ trọn +7 quy được về K4. 🔑 MỐC PRE ĐỀ BÀI SAI, bắt bằng ĐO: lead giao 143⇒192, đo LIVE lúc còn running ra 151 → truy phạm-vi thay vì hô drift (K3 đẻ 8 row AwV2_KhkkN1..N8) ⇒ đúng là 200. Mốc PRE lão hoá sau MỖI deploy. 🔑 phân rã 49+588=637 khớp cơ-chế 2-site skip-existing (588=49×12 role còn-lại) — KHÔNG suy được từ tổng ⇒ bit thật (tam-giác source ⟂ sqlcmd ⟂ Serilog). ⚠️ PERM row ≠ policy (1 row/cặp 4 cờ; "49×4=196" là POLICY). 🔑 A5 restart ×2 THẬT (PID 7020→220→6636): 8 chỉ số ĐỨNG IM + soi ĐIỀU KIỆN log trong source TRƯỚC khi đọc im-lặng (if (added>0)) ⇒ vắng dòng ⟺ 0 added; control #84 Hrm*/Off* giữ 29/377. 🔴 MARKER LEAD GỢI Ý BỊ BÁC BẰNG ĐO (Kết cấu… có sẵn từ 7a903cf ⇒ đo 1/1 = 0 bit) → thay bằng POS /khkk/list?group=1 4/4 element-wise · NEG /khkk/list?view=deleted 0/0 · 🔑 DIFFERENTIAL admin 0 / eoffice 2 (bất-đối-xứng CỐ Ý ship + tự chứng comment-strip). 🔑 ?group=abc no-token=401 (authz chặn TRƯỚC bind) → bearer re-probe 400 bind-error. ⚠️ Treo: bảng 0 dòng ⇒ chứng ống+bind KHÔNG chứng lọc-đúng-nhóm; ?group=999→200. Evidence runs/2026-07-31-S164-4gd-khkk-fanout/sub-cicd-verify-k4ab.md. Tag [run-438, phu-2-run, moc-PRE-sai, marker-0-bit, differential-marker]

  • (07-31 15349e8 S164 K3 8 workflow KHKK-N1-8 (0-mig) — PASS 6/6: #436, gate 614=45+569. 🔑 dự-đoán-TRƯỚC-khi-đo (seeder → 8wf×3step×11level + finalize 2+8=10 → khớp từng đồng + shape element-wise từng email + control ÂM OUTSIDE=2/OUTOFSET=0). 🔑 FROZEN = hệ-quả BẮT BUỘC (diff toàn // → Vite strip); marker earlyFinalizeLocked LOẠI vì tên biến local bị minifier đổi = 0 bit. ⚠️ tao chết #53 ×2. verbatim → archive/2026-07.md)

  • (07-31 0779f2d S164 K2 +Mig 71 — PARTIAL 5/6: #435, gate 609. 🔴 ACCEPTANCE RƠI VÀO CHÂN-LÝ-RỖNG — bảng 0 dòng cả PRE/POST ⇒ 0==0/NULL==NULL "xanh" mà 0 bit, backfill hụt trông Y HỆT ⇒ CẤM đọc thành PASS. 🔑 Đối-sách KHÔNG-phụ-thuộc-số-dòng: INFORMATION_SCHEMA · LIỆT KÊ TRỌN HỌ 14 index (vắng-mặt suy từ danh-sách-đầy-đủ = ĐO ĐƯỢC) · wire-proof bind-error 400. 🔑 map PID→pool bằng appcmd list wp. verbatim → archive/2026-07.md)

  • (07-31 50e6d8c S164 K1 +Mig 70 — PASS 6/6: #434, gate 598, sys.tables 96→97. 🔑 TAM-GIÁC 3 NGUỒN (source-parse ⟂ sqlcmd ⟂ API materialize qua EF — nguồn 3 mạnh nhất vì đi trọn Domain→Infra→Api). ⚠️ 0-hit là DƯƠNG-GIẢ tới khi soi format. ⚠️ hash CI ≠ hash local build. verbatim → archive/2026-07.md)

  • (07-30 bfc7b79 S162 FE-ONLY — PASS 5/5: #432, gate 590. 🔴 LUẬT CẤM HEAD~1 (Stop-hook WAL auto-commit đổi nghĩa ⇒ kết SAI; đo bằng SHA tuyệt đối X^..X). 🔑 ĐẾM TRỌN HỌ bằng 1 REGEX. ⚠️ suýt FAIL-OAN: control ÂM phải ĐỘC-QUYỀN. verbatim → runs/2026-07-30-S162-cay-4-folder-gd/)

  • (Arc S155→S161 (#416 · #419 · #422-#427) — gate 551→566. 🔑 #427 ĐO-CỜ không đếm ROW + control ÂM NỘI-HỌ (Khkk_G1 bị seeder CỐ Ý bỏ khỏi tập ⇒ phải đứng yên, và nó đứng yên). 🔑 #426 delta khớp TOÁN +23=7+7+7+2; 401 mới kèm route bịa 404. 🔴 #423 PARTIAL 8/9 revoker UNGATED lật 447/494 row, sót vì đo TRƯỚC recycle → luật 3-CHÂN-KIỀNG. 🔑 #422 marker PHÂN-BIỆT-PHIÊN-BẢN; #419 count = SỐ FILE trong diff. verbatim → archive/2026-07.md via _INDEX)

Persistent diary cross-session. Auto-injected first ~200 lines at spawn (L1 HOT). Update BEFORE every stop. Tiered Memory v1: L1 HOT soft-cap ~30KB · L2 archive/ on-demand · L3 RAG search_memory just-in-time. Keep entry ≤ 1.5K chars (gotcha #53). Full verbatim run history pre-S40 → git d2f52ba + archive/2026-05-{runs,q2,q3,q4}.md + archive/2026-06.md + archive/2026-07.md. 🗺️ Lookup map: archive/_INDEX.md — 1 dòng/bản-ghi + con-trỏ substring (sha-keyed, Ctrl-F fallback); đọc verbatim + 2026-0{5,6}.gist.md theo nhu cầu. See 🔄 Curate-trigger log for archive-move history.


🎯 Role baseline

Read-only CI/CD + post-deploy verifier SOLUTION_ERP. Poll Gitea Actions API, verify test-gate + deploy-ship + prod health. Output PASS/FAIL + evidence <500 words. Skills: iis-deploy-runbook · dependency-audit-erp · ef-core-migration.


⚠️ cicd-lane return-garble tracker (#53)

cicd-lane trả nhầm slice transcript thay verdict — tao TÁI PHẠM dai nhất roster (×5/6 qua S114; S117/S118 ×3; → feedback_agent_return_garble_recover). ⚠️ Từng tự dán nhãn 'CLEAN-return' SAIKHÔNG tự phong return sạch. 🔒 Đối-sách (S158, lần 5): ghi-đĩa TRONG LÚC LÀM — prompt đúng KHÔNG chặn được, artifact mới chặn (vai có-ép mất 0 B, vai không-ép mất TOÀN BỘ). ⇒ file trong run-folder là SẢN PHẨM CHÍNH, ghi từng mục ngay khi có bằng chứng, kết bằng END … VERDICT=; return chỉ là tóm tắt.


🚨 Recurring CI/CD bug patterns (catch priority)

  • #39 act_runner github.com TCP timeout — run hang "Set up job" 21s. Log dial tcp github.com:443 i/o timeout. Fix: manual checkout bypass hardcoded .gitea/workflows/deploy.yml. KHÔNG revert.
  • #40 npm cache tsc not foundbuild_fe_admin fail post cache: npm. DISABLED rolled back a21790d. KHÔNG re-enable.
  • #41 paths-ignore docs-only skip — code commit không trigger CI? Check git diff --name-only HEAD~1 HEAD vs paths-ignore 7-entry từ D10 S111 8aa3869 (#495): ['docs/**','**/*.md','.claude/skills/**','.claude/agent-memory/**','.claude/workflows/runs/**','.gitignore','scripts/**.md']. Gitea evaluates push range — ≥1 commit có non-ignored file → toàn range build. ⚠️ AS-6: từ #495 memory-push/run-trace HẾT trigger CI.
  • #25 IIS WebSocketnotification-hub/negotiate 401/404 prod. Fix: WebSocket module enable web.config site api (skill iis-deploy-runbook).
  • #48 SQLite tie-breakOrderByDescending(CreatedAt).First() pick wrong khi 2+ .Add() cùng frozen-clock. Fix: discriminator filter BEFORE OrderBy.
  • Bundle hash unchanged = ship FAIL — push+action success nhưng prod không đổi. Verify via INDEX.HTML ref (curl -s https://admin.solutions.com.vn/ | grep -oE '/assets/index-[A-Za-z0-9_-]+\.(js|css)'), NOT by GETting a hash-named asset directly. ⚠️ verify MUST sau status=success (Run #242 false-positive: check khi "running" → stale hash).
    • 🔴 #69 TWO-MODE — FE hash vừa có thể ROTATE vừa có thể FROZEN. deploy.yml copy dist\* UNCONDITIONALLY mọi run ⇒ 0-FE-change vẫn rotate (mode-A); src y hệt ⇒ Vite byte-identical ⇒ FROZEN (mode-B). Cả hai lành tính ⟹ hash-delta KHÔNG phải ship-proof. Ship-proof THẬT = Last-Modified in deploy-window + real-size + byte-marker. 🔑 FROZEN-lành-tính vs bundle-cũ-kẹt: xem LM — in-window = re-ship byte-identical (OK) · LM = deploy không chạm file (cờ đỏ).
    • ⚠️ SPA-fallback 200 trap (S72): server rewrite /*index.html ⇒ GET /assets/index-<BỊA>.js vẫn 200. Discriminator sạch = Content-Type (text/html ~876-919B = trap · application/javascript ~1,6MB = thật); size drift per-build nên đừng neo số byte. Hash CŨ rơi về text/html = bundle cũ biến mất khỏi đĩa = chứng ghi-đè (control âm tầng-2).
  • 🔴 Durability: đo SAU recycle + 3 CHÂN KIỀNG — pool restart ở CUỐI deploy-window ⇒ query DB lúc running = trạng thái CŨ (tao sai đúng chỗ này ở #423). Khuôn: (i) chứng minh restart thật (w3wp StartTime in-window + dòng ĐẦU log Applying migrations...), (ii) đo chỉ-số đích SAU mốc đó, (iii) control ÂM chứng checker còn sống (thiếu (iii) thì 'fix' kiểu xoá checker cũng xanh). Data-change ngoài CI luôn re-verify SAU status=success.
  • Migration drift prod vs repo — compare ls .../Persistence/Migrations/*.cs vs sqlcmd __EFMigrationsHistory. Fix: check Program.cs/DbInitializer app.MigrateDatabase() + app pool recycle. Mig-applied proof = __EFMigrationsHistory top==repo-HEAD; stuck-old ⟹ pool didn't recycle ⟹ FAIL even if status=success+bundle-rotated.

📋 5-stage checklist (EVERY run)

  • Stage 0 RAG infra: Get-Service Qdrant Running + http://localhost:6333/healthz. Collection proj_solution_erp.
  • Stage 1 Push+filter: git log -1 --format='%H %s' + git log origin/main..HEAD empty + diff vs paths-ignore (docs-only → SKIPPED-DOCS return).
  • Stage 2 Gitea poll (max 10 iter × 60s): API .../actions/tasks?limit=5 (NOT /runs 404). Match head_sha (NOT run_number — cancelled runs shift numbering). ⚠️ updated_at stale ~2min (gotcha #46) → cross-check VPS mtime. Foreground-sleep BLOCKED Windows → Monitor-style busy-wait-curl-spin ~30s/iter.
  • Stage 3 Test gate: baseline 621 PASS (45 Domain + 576 Infra; run #438 88e7ecf 08-01; climb 621/614/609/598/590/566/562/551/532/528/520/509/458/440). CI chạy cả 2 proj TRƯỚC build/deploy ⇒ status:success = gate passed (tasks KHÔNG populate conclusion — tin status). Local grep undercount (Theory/InlineData). Phase 9 UAT skip OK.
  • Stage 4 Post-deploy (if SUCCESS): auth login bearer (admin + nv.test gotcha #44; token=accessToken route /api/auth/login) → 3-5 endpoint smoke 2XX (incl new — NEW-endpoint bodyless-POST returns 411 IIS Length-Required pre-auth NOT 404; re-probe WITH body → 401 confirms wired) → FE bundle hash 2 app (per #69 = real-size-vs-fake not hash-delta) → SignalR negotiate (gotcha #25) → EF mig prod==repo.
    • Stage 4.6 (S29): sqlcmd seed verify post-deploy (NOT chỉ schema) — seed = runtime-row-insert (history/tables KHÔNG nhích) ⇒ verify bằng DB-query, không bằng bundle-frozen.
    • enum cần input SỐ (no JsonStringEnumConverter). INFRASTRUCTURE seed ungated / DEMO seed gated → #51.
  • Stage 5 Report PASS/FAIL + evidence + MEMORY update.

⚠️ Anti-patterns (DO NOT)

  1. Push fix code — READ only, escalate em main · 2. Speculate fail without log · 3. Skip post-deploy bundle hash (biggest catch) · 4. Skip MEMORY · 5. Poll forever (max 10 iter) · 6. Auto-rollback (escalate + recommend) · 7. Verify docs-only (SKIPPED-DOCS return ngay)

🧠 SOLUTION_ERP CI/CD essentials (S80 verified — re-ground từ docs/STATUS.md canonical)

  • Gitea: git.baocaogiaoduc.vn/vietreport-admin/solution-erp · workflow .gitea/workflows/deploy.yml · paths-ignore 7-entry (D10 S111 #495): ['docs/**','**/*.md','.claude/skills/**','.claude/agent-memory/**','.claude/workflows/runs/**','.gitignore','scripts/**.md']. Anon API works (public repo) when GITEA_TOKEN absent.
  • Prod: api/admin/eoffice .solutions.com.vn · SSH ssh vietreport-vps (Administrator, id_ed25519) · IIS phys paths: API C:\inetpub\solution-erp\api · admin \fe-admin · user \fe-user. DB .\SQLEXPRESS/SolutionErp/vrapp SQL-auth. Conn key = ConnectionStrings.Default (NOT DefaultConnection). DB pw = buKL3TGBkD0wDDbYVw65QeX9 (User Id=vrapp; ⚠️ Password field has NO vrapp/ prefix — S89 login-failed when prefix included; read verbatim from prod appsettings.Production.json ConnectionStrings.Default when $env:PROD_DB_PASSWORD empty).
    • SSH→PS quoting (S42): bash→ssh→powershell nuốt $var/\" ⇒ viết .sql/.ps1 rồi scp + sqlcmd -i / powershell -File (đừng nhét inline). sqlcmd -W -h -1 pw-inline. sys-catalog concat → COLLATE DATABASE_DEFAULT.
  • Tests baseline: 621 PASS (45 Domain + 576 Infra · 0 fail/skip; run #438 88e7ecf 08-01 đo LIVE ở web-UI log). 🔑 Số cụ thể lấy ở web-UI log https://git.baocaogiaoduc.vn/vietreport-admin/solution-erp/actions/runs/{run_number}/jobs/0/logs (~18KB, KHÔNG có /api/v1/ — api/v1 runs+tasks logs đều 404) → mỗi project 1 dòng Passed! - Failed: 0, Passed: N, Skipped: 0; đối chiếu TÁCH-PHẦN (45/576) chứ đừng chỉ khớp tổng. Delta test mới = so run trước.
  • Mig latest repo: Mig 71 AddKhkkApprovalGroupCatalogAndFinalizeRuntime (20260731085624, S164 K2 — AddColumn+index-swap, 0 CreateTable; applied-prod #435, GIỮ qua #436-#438). Path src/Backend/SolutionErp.Infrastructure/Persistence/Migrations/ (đếm .cs excl Designer/Snapshot). Prod check sqlcmd __EFMigrationsHistory ORDER BY MigrationId DESC. ⚠️ sys.tables(is_ms_shipped=0)=97 (sau Mig 70; 96 trước đó) — AddColumn/data-only KHÔNG đổi số ⟹ no-new-table commit giữ nguyên, đừng FAIL. NO-Mig proof = history NOT-advance + empty git diff <base>..<head> -- '*Migrations*'. Bảng mig đầy đủ → skill ef-core-migration.
  • Bundle hash live: baseline #438 (08-01) admin qOcoitOr/Cf3iCOOv · eoffice D9J3BbcA/DX1FRk5n. ⚠️ SNAPSHOT-per-run, KHÔNG phải mốc ổn định (#69) → LUÔN re-snapshot LIVE sau status=success; ship-proof = LM-in-window + real-size + marker, KHÔNG phải hash-delta. ⚠️ id ≠ run_number (key theo head_sha).
  • Prod DB anchor (POST #438, đo 08-01): MenuItems=200 · Permissions=2221 · Roles=13 · họ Khkk% = 56 menu / 728 perm (=56×13, CanRead=1 hết) · control revoker Hrm*/Off* CanRead=1 = 29/377. PK MenuItems = [Key] (KHÔNG MenuKey); Permissions(Id,RoleId,**MenuKey**,CanRead,CanCreate,CanUpdate,CanDelete) = 1 row/cặp.
  • Bearer: admin admin@solutions.com.vn/Admin@123456 (full) · UAT nv.test@solutions.com.vn/TestUser@123456 (Drafter CCM, gotcha #44 check).
  • API Serilog: sink THẬT C:\inetpub\solution-erp\api\logs\solution-erp-YYYYMMDD.log (skill-runbook …\Logs\log-*.txt STALE). Level=Information (seed/revoke lines CÓ ghi). ⚠️ deploy xoá luôn logs/ ⇒ chỉ còn từ deploy cuối. Grep revoke-line + seeder-line cùng-giây để audit seed-race. (S162: bản cũ dòng này chứa byte BEL 0x07 do \a bị nuốt — đã sửa.)

🔑 Critical config (flag commit nếu tái xuất)

Node CI 20.x (feedback_node_cicd) · MediatR 12.4.1 (gotcha #1, flag Version="14) · Swashbuckle 6.9.0 (gotcha #2) · act_runner manual checkout (#39) · npm cache DISABLED (#40, flag cache: npm)


🎯 Per-NV admin opt-in wire — 10-point checklist (cumulative S22→S23)

Cross-ref feedback_per_nv_permission_scope (10 điểm đầy đủ ở đó). 2 điểm HAY SÓT: (9) Lookup discrimination (FirstOrDefault thêm ApproverUserId==actorId + admin fallback) · (10) Controller body record count == Command record count. Miss ⇒ bug prod im-lặng 2-3 ngày.

📊 Run stats baseline

BE ~90s · FE ×2 ~60s/app · deploy ~30s · total ~3min code / 0s docs-only; gần đây 5m3x-6m3x. >8min → escalate.


📅 Recent runs (compressed — verbatim → archive via _INDEX.md)

  • (S98-S132 #383-#397 + PASS-pattern library S69b→S104 #307-#494 all GO (gate 440→509): AS-6 #41 soi TỪNG file vs 7-glob · conclusion:None dù success ⇒ tin status · 411-refine (endpoint MỚI bodyless-POST = 411 IIS pre-auth; re-probe CÓ body → 401/415 = đã wire) · LM mới hơn cửa-sổ đã verify = detector 'có run bỏ sót' · recipe SCHEMA-ADD / DATA-BACKFILL / DATA-SEED · #472 PROD Identity table NON-prefix Roles · verbatim → archive/2026-07.md + 2026-06.md)

  • Older (S83 #325 ← S29 #232) → git d2f52ba + archive/2026-06.md (incl #291 06-16 FAIL [gotcha #65]); pre-S38 → archive/2026-05-*.


🔄 Curate trigger

  • ~30KB → archive recent runs → L2 archive/<period>.md (byte-exact append) + _INDEX.md substring pointer. Dup failure patterns → merge. Stale >3mo → remove.

  • **Last curate: 2026-08-01 S166 (self #438-run: 27.3KB→~16.5KB — K2/K3/K4ab verbatim→archive/2026-07.md moved-not-cut + 3 _INDEX pointer; #416/#419/#422-#427 gộp 1 stub arc; baselines gate 621 + bundle #438 + Mig 71 + prod-DB-anchor MỚI). ⚠️ giữ luật: script sửa MEMORY phải build chuỗi XONG → temp → os.replace → verify byte>0.
  • Prev: S162 07-30 (26.9→17) · S118 · S111 20.5→17 · S107 · S104 · S98 (2026-07.md NEW) · S80 38.8→16 · S70 65.2→23.2 · S66 · S40.
  • Prev: S118 07-14 (#387/#384/#383/#496/#495→archive) · S111 20.5→17 · S107 20.4→16.9 · S104 20.5→17.9 · S98 19.9→17.06 (2026-07.md NEW) · S80 38.8→16 · S70 65.2→23.2 · S66 · S40.