Files
solution-erp/.claude/agent-memory/investigator/MEMORY.md
pqhuy1987 3d725c42f7 [CLAUDE] Docs: chốt Session 21 cuối (turn 1-5) — gotcha #46 + 2 memory mới + 4 agent MEMORY flush
Session 21 5-turn timeline chốt cuối (2026-05-12 0030 → 2026-05-13 1530):

| Turn | Topic | Commits |
|---|---|---|
| t1 | Add cicd-monitor sub-agent (4th, Path A) | 2 |
| t2 | RAG Hybrid setup planning Cách A | 2 |
| t3 | Fix gotcha #45 PE button "Trả lại" mismatch | 3 |
| t4 | F1+F2+F3 PE Workflow Mig 28 workflow-level | 5 |
| t5 | Refactor Allow* sang per-NV Mig 29 | 4 |

Cumulative 12 commits pushed remote `3a34831..c0af9e0`. No pending push.

**Gotcha mới #46** (`docs/gotchas.md`):
- Gitea Actions API path `/actions/tasks` not `/actions/runs` (Gitea v1 vs
  GitHub naming khác)
- Cache `updated_at` stale ~2 min → cross-check VPS file LastWriteTime
- Discovery từ CICD Monitor Run #186 (S21 t4) + #187 (S21 t5)
- Saved Bash command preset cho future CICD spawn

**2 Memory user-level mới** (`C:\Users\pqhuy\.claude\projects\D--Dropbox-CONG-VIEC-SOLUTION\memory\`):

1. `feedback_ef_migration_backfill_reorder.md` — Cross-project pattern:
   - EF auto-generated drop-then-add WRONG cho data preservation
   - Manual reorder ADD → BACKFILL SQL via migrationBuilder.Sql() → DROP
   - Anti-patterns: trust EF order, backfill separate migration, C# foreach
   - Down() rollback chấp nhận data loss
   - Bài học S21 t5 SOLUTION_ERP Mig 29 (48/48 Levels + 0/13 Users backfill OK)

2. `feedback_per_nv_permission_scope.md` — Cross-project pattern:
   - Multi-role workflow flag KHÔNG gắn parent table cho "tiện"
   - Split scope theo role context: Approver → Level table, Drafter → User table
   - Decision tree: role context → entity natural carry
   - UX implication: per-Level inline checkbox + User Mgmt per-user toggle
   - Bài học S21 t4 (Mig 28 SAI scope) → S21 t5 (Mig 29 ĐÚNG per-NV)
   - Trigger: user feedback "cấu hình cho từng người chứ ko phải toàn bộ"

**4 agent MEMORY.md flush:**
- 🟦 Investigator: seeds-only S21 t3-t5 (em main solo cross-stack reasoning chain)
- 🟨 Implementer: REFUSE 3× per criteria #3+#4 (correct — Anthropic warning match)
- 🟥 Reviewer: seeds-only (em main self-review build+test + CICD post-deploy)
- 🟩 CICD Monitor: 2 runs PASS (#186 + #187, ~110-120K cost each, all 5-stage green)

**Plan G Trial Week 1 evidence:**
- CICD Monitor: 2/2 PASS green = 0 fail catch (deploy clean)
- Cost: ~110-120K per spawn, under 150K budget
- CI baseline: 3-3.5 min stable
- Bonus discoveries saved: Gitea API path + prod credential fallback
- Other 3 agents: seeds-only ROI track pending future spawn opportunity

**STATUS + HANDOFF updates:**
- STATUS: Last updated S21 chốt + count 45→46 gotcha + 17→19 memory
- HANDOFF: Insert section "Session 21 chốt cuối — 5 turn timeline" trên cùng:
  - Turn-by-turn table với commits + CICD verify
  - Major schema evolution Mig 28 → Mig 29 (workflow-level → per-NV)
  - 2 pattern reusable saved memory
  - Plan G Trial Week 1 evidence table
  - Pending S22+ tree (Plan C test bundle / F2 UI / Plan B Contract V2 / etc)
  - Audit cron 2026-06-01 unchanged (threshold KHÔNG đạt sớm)

**MEMORY index user-level +2 entry** (memory MEMORY.md).

State final S21:
- 29 mig · 59 tables · ~143 endpoints · 34 FE pages
- 84 test pass (58 Domain + 26 Infra)
- 46 gotcha (+2 từ baseline 44 sau S20: #45 + #46)
- 19 memory entries (+3 từ baseline 16 sau S20: RAG + EF backfill + per-NV scope)
- 6 skills unchanged
- 4 sub-agents (3 seeds-only + 1 cicd-monitor 2-run PASS)

Pending: bro UAT continue. Plan C test-after bundle defer sau UAT 2-3 lần ổn.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 20:25:05 +07:00

6.5 KiB

Investigator Agent — Persistent Memory

Persistent diary cross-session. Auto-injected first 200 lines / 25KB at spawn. Update BEFORE every stop. Curate when > 25KB.


🎯 Role baseline

Read-only research + audit for SOLUTION_ERP codebase. Tools: Read, Grep, Glob, Bash, WebFetch, WebSearch. Output: concise structured findings under 500 words.


📋 Patterns proven (cross-session)

Pattern: Smoke verify catalog SOLUTION_ERP

  • Bearer auth từ https://api.solutions.com.vn/api/auth/login (POST email + password)
  • Status code matrix expected vs actual + JSON output + MD audit
  • Test credentials: admin@solutions.com.vn / Admin@123456 (full) OR nv.test@solutions.com.vn / TestUser@123456 (Drafter UAT scope)

Pattern: Schema scan via sqlcmd

# LocalDB Dev (runtime — primary)
sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Dev -Q "..."

# LocalDB Design (ef tooling)
sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Design -Q "..."

# Production (qua SSH vietreport-vps)
ssh vietreport-vps "sqlcmd -S .\SQLEXPRESS -d SolutionErp -U vrapp -P '...' -Q '...'"

Common queries: sys.columns, sys.triggers, __EFMigrationsHistory, COUNT(*), sys.indexes.

Gotcha: 2 LocalDB distinct (memory feedback_designtime_runtime_db):

  • _Dev — runtime API (appsettings.Development.json ConnectionStrings:Default)
  • _Designdotnet ef migrations add/update default target
  • Use --connection "Server=(localdb)\MSSQLLocalDB;Database=SolutionErp_Dev;..." override khi cần Dev specifically.

Pattern: Controller audit

  • Grep \[Route\("api/[a-z]+"\)\] enumerate ~30+ controllers
  • Grep \[Authorize(Policy = "..." audit per-action policy (gotcha #44 silent 403 class-level quá strict)
  • Grep IActionResult vs ActionResult<T> — typed return preferred
  • Grep // Mock / alert( / setEditing(null) // close UI — wire claim bugs

Pattern: Memory cross-reference

16 memory entries tại C:\Users\pqhuy\.claude\projects\D--Dropbox-CONG-VIEC-SOLUTION\memory\ (S20 +2 turn 11/12):

  • MEMORY.md — index
  • project_solution_erp.md — cumulative narrative S1-S17
  • feedback_per_chunk_commit.md — 5-chunk A-E discipline
  • feedback_uat_skip_verify.md — Phase 9 skip test rule
  • feedback_drastic_refactor_scope.md — defer dedicated session
  • feedback_audit_reuse_before_clone.md — audit-first pattern (Investigator natural fit)
  • feedback_service_hook_vs_endpoint.md — derived state hook pattern
  • feedback_n_stage_workflow_pattern.md — DEPRECATED (Mig 21 flat workflow replaced)
  • feedback_designtime_runtime_db.md — 2 LocalDB distinct
  • feedback_md_compact_narrative.md — §6.5 KEEP narrative rule
  • feedback_unittest_timing.md — §7 test timing
  • feedback_cron_monthly_limitation.md — Cron SDK 7-day expire
  • feedback_user_manual_style.md — non-tech docs style
  • feedback_node_cicd.md — Node 20.x pin
  • feedback_responsive_laptop_breakpoint.md — 4-tầng responsive pattern (S20 t11)
  • feedback_multi_agent_setup.md — 3 sub-agents setup discipline (S20 t12)
  • reference_session_prompts.md — canonical session start template

Pattern: External research priority sources

  • anthropic.com/engineering/ (official patterns)
  • cognition.ai/blog/ (Devin lessons)
  • philschmid.de + eugeneyan.com + hamel.dev (senior engineers)
  • learn.microsoft.com/en-us/aspnet/core/ (.NET 10 official)
  • tanstack.com/query/latest (TanStack Query)

⚠️ Anti-patterns observed

  • Skip MEMORY.md update before stop — lose knowledge tài sản
  • Vague conclusion "seems like" / "probably" — em main rejects
  • Missing file:line refs — non-verifiable evidence
  • Exceed 500 words — em main reads too slow
  • Scope drift to architectural recommendations — em main decides, not me

🧠 SOLUTION_ERP context essentials (auto-load)

  • DB Dev: SolutionErp_Dev LocalDB (59 tables / 27 migrations / Mig 27 latest AddVisibilityAndDisplayLabelToMenuItems)
  • DB Design: SolutionErp_Design (ef tooling distinct)
  • DB Prod: .\SQLEXPRESS / SolutionErp / vrapp user via SSH vietreport-vps
  • Tech stack: .NET 10 Clean Arch (Api → Application ← Domain + Infra) + CQRS MediatR + EF Core 10 + 2 React 19 Vite 8 TS 6 (fe-admin :8082 + fe-user :8080) + SQL Server + Gitea Actions CI + IIS prod
  • Live deploys (Prod UAT): https://api.solutions.com.vn · https://admin.solutions.com.vn · https://eoffice.solutions.com.vn
  • Gitea remote: https://git.baocaogiaoduc.vn/vietreport-admin/solution-erp
  • SSH VPS: ssh vietreport-vps (config ~/.ssh/config user=Administrator key=id_ed25519)
  • Gotchas active: 44 (reference docs/gotchas.md)
  • Tests baseline: 81 PASS (58 Domain + 23 Infra) — Phase 9 UAT skip per chunk (memory feedback_uat_skip_verify)
  • Master HEAD reference: check via git log -1 --format='%H'
  • 6 skills: contract-workflow · permission-matrix · form-engine · ef-core-migration · dependency-audit-erp · iis-deploy-runbook

🔄 Active workflow schemas (V1 + V2 coexist post-Session 17)

  • V1 Mig 21 flat workflowWorkflowDefinition pin với PE/Contract cũ. Match Dept+PositionLevel.
  • V2 Mig 22-27ApprovalWorkflow pin với PE mới + match ApproverUserId 1-1 OR-of-N cùng Cấp. Steps (Phòng) > Levels (Cấp). PE đã wire V2. Contract V2 PENDING Session 21+.

State machine 5 trạng thái phiếu PE: Nháp / Đã gửi duyệt / Trả lại (TraLai=98) / Từ chối / Đã duyệt.


📅 Recent activity (last 10 FIFO)

  • 2026-05-13 (S21 t3-t5, no spawn): Em main solo 3 turns (bug fix gotcha #45 + F1+F2+F3 workflow-level Mig 28 + refactor per-NV Mig 29). Implementer REFUSE per cross-stack reasoning chain rule. Investigator KHÔNG spawn — em main đã có context cumulative S20 t12 setup + active dev throughout. No findings to flush. Cumulative state update: 84 test, 29 mig, 45 gotcha, 19 memory entries (+2 S21 t5 pending), 6 skills unchanged. Pattern reusable saved cho future spawn: per-NV permission scope split + EF migration ADD→BACKFILL→DROP reorder.
  • 2026-05-11 (setup): Investigator agent initialized. Baseline knowledge load complete (44 gotchas + 14 memory entries + 6 skills + 27 mig + 81 test pass cumulative). No investigations performed yet. Awaiting first SendMessage from em main.

🔄 Curate trigger

  • Memory size > 25KB → archive recent entries to archive/<period>.md
  • Duplicate entries detected → merge
  • Stale > 3 months → remove

Last curate: 2026-05-11 (initial seed)