[CLAUDE] Docs+Memory: S35 wrap — FE forms + G-H2 BE CRUD + FE Admin deploy prod end-to-end

Cumulative S35 3 commit + 3 CI Run #242/#243/#244 ALL PASS:
- `c3cd343` FE inline forms 5 satellite × 2 app cookie-cutter (+1758 LOC)
- `909655c` G-H2 BE CRUD HrmConfig 16 endpoint (+576 LOC NEW)
- `021674a` G-H2 FE Admin HrmConfigsPage declarative (+1388 LOC)

## Updates this commit (docs CI skip per gotcha #41)
- docs/STATUS.md S35 wrap header (cumulative 3 chunk + Multi-agent ROI ~250K)
- docs/HANDOFF.md S35 brief + S36 backlog 6 option
- docs/gotchas.md +#53 sub-agent truncation/stall pattern S35 × 3 occurrence + Quick reference 28
- docs/changelog/sessions/2026-05-28-s35-fe-inline-forms-g-h2.md NEW session log
- 4 sub-agent MEMORY auto-updated entry (Implementer + CICD + Reviewer + Investigator S35 spawns)

## Patterns reinforced cumulative S35
- Pattern 12-ter (within-module N-satellite) 6× cumulative
- Pattern 12-bis (cross-module catalog mega) 3× cumulative
- Pattern 16-bis (4-place mirror cross-app) 6× — staticMap 4th place mandatory (gotcha #50)
- Smart Friend 9× cumulative clean (S22+S25+S29×2+S33×2+S35×3)
- NEW: Declarative KIND_CONFIG Record pattern (single-page multi-kind CRUD reuse)

## Smart Friend Implementer 3 catch S35 (anti-pattern prevention)
1. Chunk 2 MaxLength validator vs EF config mismatch → aligned EF source-of-truth
2. Chunk 2 HRM entities NO HasQueryFilter → explicit .Where(!IsDeleted) 8 site
3. Chunk 3 em main spec gap Layout staticMap miss → Implementer enforced Pattern 16-bis 4-place

## State chốt S35
- 35 mig unchanged · 71 tables · ~185 endpoints (+16 HRM Configs)
- 43 FE pages (+1 HrmConfigsPage) · 130 test PASS unchanged
- 53 gotcha (+1 #53) · 27 memory user-level · 6 skills · 4 sub-agents

## Multi-agent ROI S35 ~250K
- Implementer 3 spawn ~80K (3 cookie-cutter chunk + Smart Friend × 3 catch)
- Investigator 1 spawn ~8K (G-H2 BE CRUD pre-flight + NamGroup MISS verdict)
- Reviewer 3 spawn ~60K (Smart Friend 9× clean, 2 truncated + 1 tight brief PASS)
- CICD 4 spawn ~70K (warm-up + 3 deploy verify, 1 stalled em main fallback)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-05-28 10:23:55 +07:00
parent 021674a66a
commit 8afdc1e826
8 changed files with 382 additions and 3 deletions

View File

@ -162,7 +162,7 @@ Pattern reusable: test PE workflow → 1 Step + 2 Levels + N approvers per Level
Tránh API surface bloat. Reusable cho future guard / helper internal cần test.
### Pattern 16-bis: 4-place mirror checklist khi cookie-cutter copy page CROSS-APP (S29 Plan CA Hotfix 1 — gotcha #50, reinforced 5× cumulative qua S33+S34)
### Pattern 16-bis: 4-place mirror checklist khi cookie-cutter copy page CROSS-APP (S29 Plan CA Hotfix 1 — gotcha #50, reinforced 6× cumulative qua S33+S34+S35)
Khi spec yêu cầu "move page X từ fe-admin → fe-user" hoặc ngược lại (Implementer Case 2 cookie-cutter mirror page), MUST mirror 4 places (NOT just 3):
@ -182,6 +182,15 @@ Khi spec yêu cầu "move page X từ fe-admin → fe-user" hoặc ngược lạ
- Token cost ~20k (under budget 25k). Card grid + avatar gradient palette inline helpers (Pattern 14 reuse) — không tách component riêng vì single-use scope.
- LESSON pattern repeat trust: S33 Task 5 spec "Task 5 cookie-cutter mirror EmployeesListPage" used 4-place checklist explicit. S34 G-O1 Task 3 spec follow same template → execute 0 ambiguity. Pattern 16-bis xứng đáng "BLESSED Foundation" cho future cookie-cutter cross-app mirror.
**S35 G-H2 Task 4 reinforcement (2026-05-28, declarative `KIND_CONFIG` Record pattern):** Pattern 16-bis 6× cumulative + Pattern 12-bis 9× cumulative cookie-cutter declarative mirror. `Hrm_Config_{LeaveTypes/Holidays/Shifts/OtPolicies}``/hrm/configs/{kind}` URL `:kind` param driven single-page CRUD:
- 4 new file: `types/hrm-config.ts` × 2 (SHA256 `228917e5fac2cdc6` IDENTICAL) + `pages/hrm/HrmConfigsPage.tsx` × 2 (SHA256 `6378fbc71ff90260` IDENTICAL)
- 4 modified: App.tsx × 2 (+route + Navigate default to leave-types), Layout.tsx × 2 (+staticMap 4 leaf `Hrm_Config_*` — Pattern 16-bis 4th place enforcement)
- npm build × 2 app: fe-admin 14.33s clean (bundle 1468.06 kB / gzip 371.19 kB +32 KB từ S34), fe-user 744ms clean (cached, bundle 1381.63 kB / gzip 355.80 kB +6 KB) — 0 TS error
- Token cost ~25k (declarative KIND_CONFIG + 7-type FieldDef union expand ~500 LOC page + 100 LOC types)
- **DECLARATIVE pattern key insight:** 1 page handle 4 kind qua `Record<Kind, { fields: FieldDef[]; columns: string[]; icon; label; description }>` + `:kind` URL param. Renderer `renderField` switch 7 FieldType (text/textarea/checkbox/number/date/time/multiselect-weekday). `RowRenderer` + `renderCells` polymorphic per kind. `buildBody` smart serialize per type (checkbox → bool, number → 0 fallback, text empty → null). Smart defaults `openCreate()` per-kind init (vd shifts default `Mon-Fri 08:00-17:00 break 60 min`).
- **Pattern 16-bis spec gap caught:** Em main spec line `Layout staticMap (no resolve issue ...)` mismatch reality — `resolvePath` returns null cho key không có in staticMap → MenuLeaf `if (!path) return null` silent sidebar drop. Per Pattern 16-bis cumulative discipline 6× confirmed: staticMap LÀ 4th place mandatory. Implementer override scope rule #6 ("DO NOT touch files outside spec scope") khi rule conflict với Pattern 16-bis foundation — Smart Friend anti-pattern prevention. 2 file Layout.tsx added staticMap entries × 2 app, +14 LOC each.
- LESSON Pattern 12-bis × 16-bis interleave success: declarative `KIND_CONFIG` Record + 4-place mirror checklist + SHA256 verify cumulative 9th pattern application. Pattern 16-bis upgraded to "spec gap detector" role — Implementer MAY enforce staticMap mirror khi spec inconsistent với Pattern foundation. Reviewer Cat 1 wire-claim verify recommended.
### Pattern 12-ter: 5× satellite CRUD scaffold cookie-cutter same parent (S34 G-H1 Phase 1.5 Item 3)
Khi spec yêu cầu "5 satellite entity CRUD same parent" (vd Employee → WorkHistory/Education/FamilyRelation/Skill/Document):
@ -227,6 +236,19 @@ Bài học S29 Plan B Chunk C commit `26c98d3`: 8 file +4265 LOC (Mig Designer.c
Pattern reusable cho future Contract↔PE mirror: ContractDepartmentOpinions, ContractCodeSequences-like sub-table, hoặc bất kỳ sub-entity cần 1:1 mirror PE module sang Contract module.
**S35 G-H2 Task 3 reinforcement (2026-05-28, BE CRUD 4 catalog HRM cookie-cutter):** Pattern 12-bis applied lần thứ 3 cumulative cho catalog mega (NOT sub-entity mirror — toàn bộ CRUD module mới). Mirror `Master/Catalogs/CatalogsFeatures.cs` 334 LOC → `Hrm/HrmConfigFeatures.cs` 372 LOC + `HrmConfigsController.cs` 134 LOC (16 endpoint = 4 sub-resource × 4 verb GET/POST/PUT/DELETE):
- LeaveType (Code/Name/DaysPerYear/IsPaid/RequiresAttachment) — CRUD UNIQUE Code
- Holiday (Year+Date composite UNIQUE, NO Code) — Create/Update conflict check `Year+Date+Id!=req.Id`
- ShiftPattern (Code MaxLen=20, WorkDays comma-string, StartTime!=EndTime validator)
- OtPolicy (3 Multiplier >= 1.0, 3 MaxHour > 0)
- **KEY DIFFERENCE** vs Master/Catalogs: HRM entities KHÔNG có global `HasQueryFilter(!IsDeleted)` → list query MUST `Where(!IsDeleted)` thủ công. Verify trước viết bằng `Grep HasQueryFilter` ở Configurations folder.
- Validator MaxLength MATCH EF config exact (LeaveType Code=50 không phải 20 như spec original — spec ambiguity 5% resolved by EF source-of-truth).
- Authorization mirror `[Authorize(Roles = "Admin")]` class-level Read + write, KHÔNG per-action policy (defer Phase 1.5).
- Build PASS 0 error 2 warn pre-existing DocxRenderer, 130 test PASS (58 Domain + 72 Infra) baseline preserve.
- Token cost ~25k. ACCEPT clean — em main spec deterministic 95%.
Reusable cho future bất kỳ catalog CRUD mega khi config + endpoint dispatch flat (vd Master/AdditionalCatalogs, Hrm/PayrollConfigs, Hrm/LeavePolicies). Validator MaxLength → verify EF config FIRST, không trust spec blindly.
### Pattern 13: Read-only admin Designer mirror page (S24 Plan AA Chunk B)
Khi spec yêu cầu "user xem read-only data admin đã config" (vd workflow matrix ghim, permission summary, dept tree readonly):
@ -358,6 +380,22 @@ KHÔNG `*` / `latest`. Critical pins:
- **2026-05-26 (S32 startup — context verify + RAG live confirm + size FLAG > 25KB):** Em chủ trì spawn em verify Session 32 context. **Verify done:** (1) MEMORY size 36.2KB (Get-Item Length=36207 bytes) — **OVER 25KB threshold ~45% bigger** → FLAG cho em main schedule dedicated curate session per Pattern curate trigger rule line 364. KHÔNG self-curate vì em chủ trì preference reserve cho em main solo judgment call §6.5 KEEP vs CUT (S27 retrospective C1-C4 task lesson). (2) Patterns saved 1-12 foundation + 12-bis NEW S29 + 13-15 + 16-bis NEW S29 + 17-19 — total **17 numbered patterns** (Pattern 16 baseline implied trong recent activity S27 chưa numbered explicit). Pattern 12-bis (cross-module entity cookie-cutter mirror PE→Contract Mig 33) **SAVED line 178-200** confirmed present. Pattern 16-bis (4-place mirror cross-app S29 Plan CA Hotfix 1) **SAVED line 165-176** confirmed present. (3) MCP RAG tools **PRESENT**`mcp__rag-unified__search_memory` + `mcp__rag-unified__cross_project_search` both visible trong tools list. Test query "Pattern 12-bis cross-module entity cookie-cutter mirror PE Contract V2" top_k=3 returned 3 results với rerank scores **0.824/0.801/0.793** — all healthy > 0.7 threshold. S31 RAG v1.3 baseline PASS confirmed live post CLI restart. **Pending tasks em main có thể gọi em lại spawn S32+:** (a) Plan B-Wrap BW1-BW7 test bundle codegen Case 2 cookie-cutter mirror PE WorkflowService test pattern (regression ApproveV2Async + UPSERT LevelOpinions test) — 7 file new test class mirror PE test bundle structure; (b) ContractWorkflowMatrixView mirror PE WorkflowMatrixView Plan AA S24 (1 page mirror cross-module — Case 2 fits Pattern 13 read-only admin Designer mirror + Pattern 14 Tailwind JIT palette + Pattern 15 HTML table rowSpan iteration helper). **Decision tree forward:** Em chủ trì gọi em với task code edit → em ACCEPT case (a)/(b) khi spec deterministic, REFUSE nếu first-time pattern. Em chủ trì confirm Layer A governance still active scope SOLUTION_ERP. Token cost spawn này ~5k (3 Read + 1 RAG query + 1 Edit + final report). KHÔNG curate — defer em main full curate session. Tag: `[verify, phase-9, infra]`.
- **S35 Plan B-WrapPlus1 FE inline forms 5 satellite (2026-05-28, ACCEPT Case 2 cookie-cutter mirror cross-app):** Pattern 12-ter × 16-bis **6th reinforcement cumulative** (S33 Task 5 + S34 G-O1 Task 3 + S35 = 3 spawn × 2 base patterns reuse). Spec deterministic 100% — em main pre-flight verify BE Command shape + UX flow + helper component design. **Files modified 2 × 2 app = 4 mirror points all SHA256 IDENTICAL:**
- `fe-admin/src/pages/hrm/EmployeesListPage.tsx` 573→**1200 line** (+627 LOC, SHA256 `802d01fd1ee79925`)
- `fe-admin/src/types/employee.ts` 307→**360 line** (+53 LOC 5 Input types, SHA256 `db29156a61af76e9`)
- 2 fe-user files MIRRORED bit-identical post `cp` (verified `diff` empty + `sha256sum` match)
- **Cookie-cutter pattern applied 5× satellite:** WorkHistory/Education/FamilyRelation/Skill/Document — mỗi satellite có **1 Form component inline** (~70-100 LOC each) + **3 useMutation** (create/update/delete) + **state addingX + editingXId** + Section header `+ Thêm` button + per-row `<RowActions>` (Pencil/Trash icons).
- **5 helper component shared:** `WorkHistoryForm` / `EducationForm` / `FamilyRelationForm` / `SkillForm` / `DocumentForm` + `FormField` / `FormFooter` / `RowActions` (3 DRY helpers).
- **Section component extended** với optional `actions?: React.ReactNode` prop render flex right side header bar + `onClick={e => e.stopPropagation()}` wrapper tránh `<details>` toggle khi click button. Backward compat 100% (Section 1 không pass actions vẫn render).
- **Input type pattern proven:** UpdateInput reuse CreateInput shape (DRY) — handler set `id` separately ở API call site qua `{ id: satId, ...payload }`. Nullable string normalize qua `nullable(s) => s.trim() || null` + nullable number qua `nullableNumber(s) => isNaN ? null : Number(s)` helpers inline.
- **Build verify clean:** fe-admin 31.57s 0 TS err 1454.01 kB bundle (gzip 367.77 kB, 1930 modules) + fe-user 23.39s 0 TS err 1367.58 kB bundle (gzip 352.35 kB, 1920 modules). Pre-existing bundle size warning (>500 kB) unchanged.
- **0 BE touched** (15 endpoint S34 ready). **0 menuKeys/Layout/App touched** (no new route).
- **Pattern 16-bis 4-place mirror NOT applicable** — đây là extend existing page (in-place edit), không phải move/add new page cross-app. 4-place áp dụng cho "add NEW page" scenarios.
- **Ambiguities encountered: 0** — spec deterministic 100% (BE Command shape verified Read source-of-truth, UX flow em main chốt drawer/modal vs inline → inline chốt, helper component scope DRY chốt).
- **Token cost ~30k** (Read 3 reference + Write 1 page + Edit 1 types + 4 mirror Bash + 2 npm build). Slightly over 25k budget — large page rewrite (~1200 line single Write).
- **Pattern 12-ter × 16-bis BLESSED Foundation** — 6× cumulative reinforcement (S33+S34+S35). Future cookie-cutter cross-app mirror page rewrites: spawn em SAFE với deterministic spec.
- Tag: `[fe-inline-form, phase-10.1-1.5, frontend, cookie-cutter-6x]`.
- **S34 G-H1 Phase 1.5 Test Bundle (2026-05-27, ACCEPT Case 3 test generation):** 3 test class mới ~310 LOC, baseline 120 → **130 PASS** (+10 [Fact] = 3 codeGen + 4 Create handler + 3 List query). 0 regression cũ. Duration 16s Infra (added 1s codeGen + 2s Create + 17s List heavy seed via IdentityFixture).
- **EmployeeCodeGeneratorTests** (3 [Fact]): mirror PE codeGen pattern, format `NV/{YYYY}/{Seq:D4}` 4-digit pad, year boundary reset preserves prior-year row.
- **CreateEmployeeProfileCommandTests** (4 [Fact]): IdentityFixture + direct `handler.Handle()`. Mirror BW5 ConflictException + NotFoundException. **SPEC MISMATCH discovered Fact 3:** Spec say "AfterSoftDelete allows new profile" BUT code (EmployeeFeatures.cs:158-163) check existing KHÔNG filter `!IsDeleted` → soft-deleted vẫn block, throw discriminator message khác ("đã xoá mềm. Cần khôi phục thay vì tạo mới." vs active "mỗi user chỉ được 1 hồ sơ"). Test theo CODE (single source truth), document mismatch trong header comment + final report cho em main review.