Files
solution-erp/.claude/agent-memory/harvest-curator/MEMORY.md

51 lines
19 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Harvest-Curator Agent — Persistent Memory
> **Persistent diary cross-session.** Auto-injected first ~200 lines at spawn (L1 HOT).
> Update BEFORE every stop. Tiered Memory v1: **L1 self-target ≤17.1KB (hook read-limit 24.4KB)** · L2 `archive/` on-demand · L3 RAG `search_memory` just-in-time. Keep entry ≤ 1.5K chars.
> **NEW agent 2026-06-07** (adopt AI_INFRA Harness 1 — H2 harvest-integrity; TÁCH khỏi tooling-auditor H1 per anh-mandate "H1/H2 hay quên+nhầm → riêng-biệt").
---
## 🎯 Role baseline
H2 harvest-MD-integrity auditor **SOLUTION_ERP-self**. Read-only + **propose-only** (em main = single-writer, VERIFY→APPEND B3; ngoại lệ duy nhất = diary chính mình khi em main cho phép). Verify HARVEST mỗi session ĐỦ+ĐÚNG **5-trục**: Coverage · Completeness · Fidelity-FLAG · Placement · Corruption. @session-end GATE trước đóng + gom run-folder; @session-start báo harvest mới + delta mồ-côi + orphan run vs ledger.
## 🚫 Split boundary
- ✅ MINE: harvest-memory integrity (5-trục) + spawn-record 4-field + run-folder gom (Harness-10) + delta mồ-côi — SOLUTION_ERP-self
- ❌ NOT: tooling/skill/plugin/docs-freshness → **tooling-auditor** (H1) · corpus/RAG/deploy → cicd-monitor · Fidelity tự-phán "bịa" → escalate **reviewer** · write/decide → em main
## 📋 Baseline state (re-ground S99)
- **Spawn-record 4-field SE:** `{task · verdict · learned · surprise}` (memoryDelta R1 contract HMW).
- **agent-memory:** 12 folder `.claude/agent-memory/<role>/MEMORY.md` (placement target — S107 +office-document seed). Cap L1 = 25.6KB (H11 `memory-archive-gate.ps1`); hook self-target 17.1KB.
- **Run-trace (Harness-10, thay wave-folder Harness-2):** `.claude/workflows/runs/<run-id>/` git-TRACKED, FLAT (`run.md` + `sub-*.md` + `*-synthesis.md`); 5 run cũ 06-18 giữ `sub-md/`+`harvest/` subfolder (dual-accept). **🧊 Ledger `runs/_ledger.md` RETIRED H18-B S100** (true-catch 0/15 lifetime + mode-A coverage 0/8; 15 row frozen giữ lịch-sử) — **orphan-authority = folder-scan:** folder có `run.md``*-synthesis.md` VẮNG/0-byte. Mode-A ephemeral (S98 note): HMW default KHÔNG tạo run-folder = by-design, vắng folder ≠ orphan.
- **Nền H2 gốc:** `session-end.md` Phase 1.5 §L.b = 3/5 trục; sub này nâng +Fidelity-escalate +Placement = đủ 5.
## ⚠️ Anti-patterns
❌ Tự ghi/overwrite memory ngoài diary mình (propose→em main APPEND) · ❌ tự phán Fidelity "bịa" (→ reviewer) · ❌ tick "đã flush?" nhị-phân (phải đủ 5-trục) · ❌ đụng tooling-freshness (đó là tooling-auditor) · ❌ G-015 overclaim "read-only enforced" · ❌ final-message trả narrative memory-curation thay verdict (#53 return-garble).
## ⭐ Methods (giữ vĩnh viễn — đúc từ S50-S66, verbatim → `archive/2026-06.md`)
1. Chunk-count qua **RAG MCP `list_projects`**, KHÔNG shell-probe Qdrant (MCP trỏ host khác → false-negative).
2. Sub killed-mid-write → verify tail **terminates-clean** (`wc -l` + closing-Tag), KHÔNG chỉ `-size 0` (partial-write ≠ 0-byte).
3. Detect interrupted-session: so **mtime agent-memory vs closeout-commit timestamp**.
4. Commit-stat "có append" ≠ "có fanout-record" — classify bằng **grep tag session + mtime**, đừng tin stat.
5. Extract added-bullet trong diff: `grep "^+-"` (filter `grep -v "^[+-][+-]"` NUỐT dòng `+- **…`).
6. `tail -c N` cắt giữa UTF-8 multibyte in ra ký-tự-thay-thế GIẢ — corruption thật = **grep literal U+FFFD** (đừng viết literal đó vào L1 kẻo tự false-alarm).
7. Mojibake quoted-cũ vs mới: **arithmetic line-shift** = đúng số dòng insert phía trên → cũ.
8. Sub die không để delta → **commit-body = spawn-evidence** (S60 reviewer tự khai trong msg).
9. U+FFFD self-quote trong file MÌNH + archive = quoted-evidence cố-ý — đừng false-alarm.
10. Trend self-tag session-drift (cicd s50→s51 · inv s56→s57 · inv s57bis→s58 · cicd s98→s97 ×4): entry mới soi tag vs session thật.
## 📅 Recent activity (FIFO — older → `archive/`)
> **S50→S66 (14 entry) verbatim → `archive/2026-06.md`** — curate S99 (hook 19.9KB > self-target 17.1KB), moved-not-cut grep-verified 5/5 + entry-count 14. Digest: verified-runtime S50 · GATE PASS 5/5 ×6 (S50/51/58/59/63/66) · chuỗi 4-MISS post-S57bis rushed-closeout + reviewer die ×3 (S57bis ×2 + S60) · cicd over-cap saga 32→86.8KB → curate S66 86.8→28.9KB.
> **S98→S101 (4 entry) verbatim → `archive/2026-07.md`** — self-compact 2026-07-10 @S109-start (plan đứng từ S107/S108; block-md5 `e2b906336b4cdad3034329cffc09525a` moved-not-cut). Digest: S98/S99/S100 @start-report chuỗi CLEAN (3 orphan-append S97 đóng · cicd #485 orphan-sane arithmetic-fidelity · tooling live-delta bootstrap) · S101 GATE PASS 5/5 + AS-10 Fidelity-call LEGIT-KEEP (keep-if-correct, 0 fabrication).
- **2026-07-06 (S102 @start RE-REPORT — self-write per em-main instruction):** Model self-report `claude-fable-5`. Coverage/Completeness/Corruption CLEAN: git-porcelain 0 dirty ⟹ **0 delta mồ-côi by-construction** (mtime agent-memory ≤18:31:37 < closeout `3e2c18b` 18:32:11, method-#3) · orphan-run **14/14 PASS** folder-scan, 0 folder July = 3 WF S101 mode-A by-design · 0-byte 0/11 · tail 11/11 `0a` · U+FFFD L1 0/11 (2 archive hit quoted-cũ known). AS-10 KEPT entries reviewer VERIFIED intact: `:13` H18 `wf_955643c3` + `:14` H19 Lane-C + `:22` H19 Lane-A (f229b07/e350660). 🔴 **CATCH ×2 FLAG (miss của chính gate S101 mình):** (1) f229b07 XÓA 5 verbatim (S97·S97-bis·S98×3) khỏi reviewer L1, digest claim "Detail archive/2026-06.md" nhưng grep 0/0/0 + archive mtime 06-20 = **cut-not-moved**, verbatim chỉ còn `git show 5ee32c0:` propose recover `reviewer/archive/2026-07.md` + _INDEX; (2) `:72` pointer `project_s100_h18_wf2_synthesis.md` chưa-từng-tồn-tại (git log --all rỗng) = dead-satellite; minor `:22` lạc section Role-baseline. Đối-chứng: cicd f229b07 nén IN-PLACE (giữ one-liner trong L1) = pattern sạch. **Method-new: L1 net-shrink + claim "Detail→archive" = PHẢI grep archive moved-not-cut TRƯỚC khi PASS — "net-shrink healthy" S101 là verdict thiếu trục.** Chore: impl-be 23955B idle · fe-designer 21.5K / inv-cb 20.6K / reviewer 19.4K / cicd 18.4K > self-target 17.1K watch. Tag `[s102-start, cut-not-moved-catch, dead-pointer, 0-orphan-delta]`.
- **2026-07-06 (S104 mid-session RE-REPORT — retro-append tại S105, on-behalf em-main B3; nguồn session-log S104:19):** Task: 5-trục verify post-`778fc98` (Mig 62 Supplier docs-lag). Verdict CLEAN — investigator-harvest-in-HEAD **moved-not-cut** (arithmetic 18 AddColumn/2 Sql-guard/0 CreateTable · PathLink 2497B byte-identical 2-app · CaHai=6 append) + 3 cicd file uncommitted **commit-worthy** (DEDUP clean, #488 not-in-HEAD → landed `9f9a78e`) + 0 orphan-delta khác + 0 orphan-run + 0-byte 0/11. Learned: verdict chỉ nằm session-log, spawn-record chính mình không ai append (`9f9a78e` thiếu harvest-curator) = **self-record blind-spot của gate-agent**. Tag `[s104-retro, self-record-gap, on-behalf]`.
- **2026-07-07 (S105 @start RE-REPORT — on-behalf em-main B3):** Self-report `claude-fable-5` (inherit-chain Fable evidence, flip-6 S105). 4 mục: (1) harvest-mới **0** — porcelain clean + 0 file newer-than-closeout `95f5555` + 0 run-folder July (mode-A by-design). (2) **Mồ-côi ×1** = record H2-S104 (session-log S104:19 có verdict, agent-memory không) → retro-append entry trên. (3) Orphan-run **0/14** folder-scan (run.md=1 · syn_nonzero=1 · syn_zero=0 cả 14, dual-accept). (4) 0-byte 0/11 (runs chỉ 10 `.gitkeep` by-design) · U+FFFD L1 0/11 · tail 11/11 `0a`. Learned: entry tag bằng date+wf-id (`wf_5ac2cdb0`) làm grep "S###" false-miss → phán missing-record PHẢI grep thêm date/wf-id. Method-#5 self-trap tái diễn (filter `^[+-]{2}` nuốt `+-` bullet) — caught. Chore-watch: impl-be 23955B = 93.6% cap (đứng-im từ 06-25). Tag `[s105-start, h2-self-record-moc-oi, 0-orphan-run, on-behalf]`.
- **2026-07-07 (S106 @start RE-REPORT — self-write diary):** Model `claude-fable-5`. Verdict 🟢 **ALL-CLEAN 5/5 trục, 0 harvest-mới, 0 mồ-côi** (same-day post-S105). Evidence: (Coverage) S105 harvest commit `54a2c72` --stat = 3 file touched khớp 2-monitor+1-investigator: harvest-curator +3 (S104-retro/S105-start/S105-close) · inv-cb +1 (BVAAU RCA) · tooling +10±5 (self-append + self-compact archive). **cicd-monitor KHÔNG spawn S105** (last-entry đúng S104 #488 `:54`; grep "S105" cicd=0 = ĐÚNG, không phải miss) — resolved false-alarm. (Corruption) 0-byte 0/11 · tail-0a 11/11 · U+FFFD 0/11 (cả working-tree). (Placement) porcelain CLEAN ⟹ 0 delta mồ-côi by-construction (method-#3: mọi agent-memory mtime ≤17:12:23 < closeout `41f8061` 17:13:10). (C5 orphan-run) 14/14 PASS folder-scan (run.md=1·syn_nz=1·syn_z=0 cả 14), toàn 06-18, **0 folder July** = S105 3-WF mode-A ephemeral by-design. **Reference-table drift resolved BENIGN:** task-prompt table (cicd 17542/inv-cb 17337/reviewer 20728/self 20438) = `memory-budget.json.measured` block = **S98 snapshot chưa re-measure post-S104/S105** (line 120 _note "S98 FRESH re-measure"), KHÔNG phải live live disk (cicd 19203/inv-cb 17229/reviewer 20071/self 14439) phản ánh S104-S105 curate+grow; direction đúng (self SHRINK do S99+S105 self-compact · cicd grow-then-curate) = 0 truncation, 0 "0-when-nonzero". Method-new: **prompt-cấp reference-table có thể = frozen budget-snapshot; cross-check `memory-budget.json._note` DATE trước khi phán size-drift = corruption** (S98-table vs S106-disk lệch = staleness không phải hỏng). Method-self-trap tái diễn: compound `grep|head` Bash trả empty-output GIẢ (shell-quote glitch) nghi false-absence; xác nhận bằng Grep-tool + git-show riêng-lẻ (cicd file nguyên-vẹn 19113B@HEAD). Chore-watch: impl-be 23955B = 93.6% cap đứng-im từ 06-25 · fe-designer 21492 / reviewer 20071 / cicd 19203 > self-target 17.1K garble-pressure watch. Tag `[s106-start, 5truc-clean, 0-moc-oi, ref-table-s98-snapshot, cicd-not-spawned-s105]`.
- **2026-07-07 (S105 @close GATE — self-write diary, tránh lặp S104 blind-spot):** GATE **PASS 5/5 trục**. Coverage 3/3 spawn + 1 resume: tooling S105 self-entry L1 · harvest 2 entry on-behalf (S104-retro + S105-start, diff +2) · investigator BVAAU on-behalf (+1, garble-#53 lần-7 SendMessage-resume documented in-entry) — đủ 4-field, đúng nhà cả 3. Corruption: 0-byte 0/11 · tail 0a 11/11 · U+FFFD L1 0/11 + archive tooling HEAD=0/now=0. **Moved-not-cut VERIFIED byte-level** (tooling self-compact 19380→16305B): S99/S100 md5 MATCH · S101 @closeout cmp IDENTICAL 1580B=1580B · S98-drop lossless (superset frozen @HEAD archive: mEGqlNWc/s98-start/HẬU-monthly 3/3 hit). Fidelity spot: skills/README:20 stale-claim TRUE (HEAD "Mig 61/S98" → now "Mig 62/S104" em-main flushed). C5: runs/ 14 folder toàn 06-18, 0 July, mode-A by-design. Method-new: **verbatim-compare PHẢI anchor substring entry-unique — grep "(S101 @" head-1 bắt nhầm S101-@start (còn sống L1) thay @closeout → false-DIFF; anchor "(S101 @closeout CHỐT" mới đúng cặp.** Minor cosmetic: archive note "2 entry moved" thực 3 (S101 marker riêng) — 0 mất data. Chore: inv-cb 17229B chớm qua 17.1K · impl-be 23955B idle. Tag `[s105-close-gate, 5truc-pass, moved-not-cut-bytelevel, grep-anchor-trap]`.
- **2026-07-10 (S107 @start RE-REPORT — self-write diary):** Model `claude-fable-5` (Fable VỀ flip-8). Verdict 🟢 **ALL-CLEAN 5/5 trục + 0/14 orphan-run** — đối tượng = S106 micro-session 7-file uncommitted (3 memory + 4 docs). **Moved-not-cut VERIFIED md5 3/3** (tooling self-compact S106: S102 `1760f27a` · S103 `a6c8c75f` · S104 `e12e5377` — anchor `(S10x @start RE-REPORT` đúng 1-hit HEAD-L1 + 1-hit archive + 0-hit L1-now; arithmetic ~8.0KB moved khớp 17316→14867 + ~5.6K added). Coverage: mtime-scan khớp porcelain đúng 3 file post-closeout `41f8061` (17:26-17:29 07-07; harvest +1 = entry S106 mình tự-ghi · tooling L1+archive), 0 hidden delta (`.mfe-state.json` = gitignored:124 by-design). Fidelity cross-check MẠNH: claims trong tooling-S106-entry khớp docs-diff thật (STATUS:27 hoist #488 `ChSNAJBK`/`Bn2w1znH` + :24 S106-O flip-7 + 3 derived de-enumerate→canonical per anh-confirm) = record khớp việc-thật. Corruption: 0-byte 0 (10 `.gitkeep` by-design) · tail 11/11 L1 + archive `0a` · U+FFFD 0 L1 + 0 file-changed (4 hit = 2 archive 2026-06 quoted-cũ known). Cosmetic ×2, 0 data-loss: archive header "hook 19.7KB" không reconstruct được (HEAD 17.3K / pre-compact ~22.4K) · entry S106 chèn TRƯỚC S105@close trong diary mình (order lệch, có date nên grep OK — từ nay append CUỐI file). Propose: commit 3 memory-file vào bundle đầu S107. Tag `[s107-start, moved-not-cut-md5-3of3, all-clean, fable-flip-8]`.
- **2026-07-10 (S107 @end GATE — self-write, resume in-session):** GATE **PASS 5/5 trục**. Coverage 4/4 spawn-record committed (tooling @start `1eea51b` [@end in-flight song-song] · harvest @start · cicd #489 · office-document entry-đầu 3323B `86a34d5` — 12th sub, 4-field đủ, fidelity khớp commit-sequence "pending CLI-restart"→"hot-reload ĂN THẬT" + 2 claim lớn em-main cross-verified độc-lập). +31B trên L1 mình = `21387cd` baseline 11→12 folder (em-main wire hợp lệ, entries nguyên). C5: runs/ = 14 dir 06-18 + 2 FILE (README/_ledger frozen) — `ls`-16 ≠ 16-folder, 0 folder mới = Agent-tool-only by-design. 0-byte 0/toàn-tree · tail 12/12 `0a` · U+FFFD 0 L1. Method-#5 trap lần 4 (filter nuốt `+-` bullet) — caught in-flight. **Self-compact phiên sau: move S98→S101 (4 entry đầu Recent, ~5.4KB) → archive/2026-07.md MỚI + md5-verify moved-not-cut** (L1 18.9→~13.5KB). Tag `[s107-end-gate, pass-5truc, od-12th-seed-verified]`.
- **2026-07-10 (S108 GATE — self-write, resume lần 2):** GATE **PASS 5/5**. Coverage 3/3 (inv-cb + reviewer on-behalf `69957fd` engine-label GAP-2 `[engine: fable-real-single · Fable-S108]` đúng format-đầu-tiên · cicd #491 tự-ghi `5d13b48`) + 4 worker role-less 0-folder đúng chuẩn. Fidelity: verdict khớp gốc (invest PARTIAL 103/111 · reviewer FAIL 1C/4M); 2 entry độc-lập cùng kể honesty-trap hmw.js:31 khớp commit-fix. **Moved-not-cut md5 4/4:** cicd #489 `25633942` / #488 `d8539bb2` (curate-note "content-exact" PROVEN, L1 giữ italic-digest + _INDEX +2 pointer) + tooling-S107close S105@start `c7a9e745` moved, S105@closeout+S107@start KEPT (backstop idempotent). Mojibake-sig (FFFD/â€/Ä‘/á) 0/12 python-write sạch · 0-byte 0 · tail 12/12 `0a` · C5: 14 dir + 2 file, 0 folder mới = wf_2f85b3f6 mode-A by-design. Method: anchor multi-hit cross-ref (5 dòng "#489" L1) → md5 PHẢI thu về dòng run-record duy-nhất `**🟢 S107 #489 (rn`. Self-compact proposal ĐỨNG phiên sau. Tag `[s108-gate, pass-5truc, engine-label-first, md5-4of4]`.
- **2026-07-10 (S109 @start RE-REPORT — post-S108-closeout `557642f` + PAUSED-sleep-mini-phiên `a9c3f1d`, self-write diary):** Model `claude-fable-5`. Verdict 🟢 **ALL-CLEAN 4 mục + sleep-resume-point disk-MATCH**. (1) Harvest-mới 0: porcelain clean + diff `557642f..HEAD` agent-memory/workflows RỖNG ⟹ PAUSED ghi 0 entry (đúng kỳ-vọng, chỉ HANDOFF +1/1) · 0 mồ-côi by-construction (method-#3: 12 L1 mtime ≤15:36:58 < closeout 15:39:25). (2) Orphan-run 0/14 (run=1·syn=1·syn0=0, toàn 06-18, 0 folder July wf_2f85b3f6 mode-A). (3) Corruption 0: 0-byte 0 · tail 12/12 `0a` · U+FFFD L1 0/12 (2 hit archive-06 quoted-cũ known) · mojibake-sig 1 hit = dòng S108 self-quote MÌNH (method-#9). (4) Sleep disk==resume-point HANDOFF:5: 16/16 scope-file verbatim non-zero · gist-scan 11 hit TOÀN month-level git-log 06-1707-02 tiền-PAUSED 0 gist MỚI · `last_sleep_at`=2026-07-02 giữ (json:4) · command `/sleep-recovery-memory-l2` tồn tại. INFORM: lượt-A cicd propose = transcript-lost 0 dấu disk (HANDOFF đã encode re-run từ lượt-A 0 mất data, verbatim nguyên); retro-đóng self-record spawn-PAUSED tại đây (S104 blind-spot pattern). Self-compact executed: S98S101 `archive/2026-07.md` MỚI block-md5 verified, L1 20.2K→~15.7K. Chore: impl-be 23955B 93.6% idle · fe-designer 21.5K · reviewer 21.1K · inv-cb 18.2K · cicd 17.8K > 17.1K watch. Tag `[s109-start, sleep-resume-disk-match, 0-gist-new, luot-a-transcript-lost, self-compact-2026-07]`.
- **2026-07-10 (S109 sleep-recovery Phase-1 GATHER — propose-only, TEXT-return):** Đọc 2 archive 2026-06 (tooling 16.4KB + harvest-SELF 17.1KB) → trả lead 5+5 gist-draft 4-field + coverage-inventory 5-lớp + back-resolve 10/10 substring grep-verified UNIQUE. Self-archive xử nghiêm gấp đôi: giữ nguyên flag tự-bắt (self-quote `:33` trap · suýt-false-MISS diff-filter · chuỗi 4-MISS post-S57bis). 0 file dự án ghi. Tag `[s109-sleep-p1, gather-propose-only]`.
- **2026-07-11 (S110 @start RE-REPORT — self-write diary):** Model `claude-fable-5`. Verdict 🟢 **ALL-CLEAN 4 mục** (post-S109 closeout `72a85bf` 18:14:34). (1) Harvest-mới 0: porcelain 0 dòng + find-newermt-closeout = **0 file** agent-memory/runs ⟹ 0 mồ-côi by-construction (method-#3). (2) Orphan-run **0/14** folder-scan (run=1·syn_nz=1·syn_z=0 cả 14, toàn 06-18; 0 folder July = S109 sleep-P1 Agent-tool/mode-A by-design). (3) 0-byte **0** (ex .gitkeep); 2 gist S109 non-zero VERIFIED: tooling `2026-06.gist.md` 6141B + harvest-SELF 6544B; U+FFFD L1 0/12. (4) Idempotent spawn-record S109 đủ nhà: cicd #492 = 2 hit (:55/:73, `72a85bf` +3-line) · tooling "S109" ×4 · harvest 2 entry (:48/:49) · reviewer curate f5a5c3e (L1+archive+_INDEX). Method-note roster-count: `ls` agent-memory = 13 item = 12 folder + `memory-budget.json` (FILE — đếm folder chuẩn = find MEMORY.md maxdepth-2 = 12, đừng phán 13th sub). Chore-watch: impl-be 23955B 93.6% idle từ 06-25 · fe-designer 21.5K · cicd 18675B (+#492) · inv-cb 18.2K · reviewer 17.4K ↓post-curate · SELF 17227B chớm target → sau entry này ~18.6K, đề-xuất self-compact S102→S105 phiên tới. **RE-RUN lượt-TỐI (amend DEDUP, không double-append):** entry gốc ghi 08:27 lượt-SÁNG S110 — return không tới em-main (transcript-lost, em-main tối hỏi "+1 dòng là gì") → re-spawn re-verify 4 mục KHỚP 100%, thêm chứng: gist byte-exact `git cat-file -s f5a5c3e:` == disk (6141/6544, FFFD 0, tail `0a`) · reviewer-S109 in-HEAD (:92 P3b fidelity-gate + :98 curate) · find-newermt = đúng 2 file M. tooling +1 dòng = S110-entry của NÓ (mtime 19:10 lượt-tối, fidelity khớp `f5a5c3e` 10-file agent-memory-only + `72a85bf`). Cả 2 M = diary hợp-lệ → propose commit bundle đầu S110. SELF thật 18483B. Tag `[s110-start, all-clean, 0-moc-oi, 0-orphan-run, rerun-dedup, luot-sang-transcript-lost]`.