Files
solution-erp/.claude/agent-memory/harvest-curator/MEMORY.md
2026-07-12 17:11:07 +07:00

19 KiB
Raw Blame History

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). S102→S106 (5 entry) verbatim → archive/2026-07.md — self-compact 2026-07-12 @S111-start HOOK-directed (plan ĐỨNG từ S107/S108/S110; mở-rộng +S106 để đạt <17.1KB; block-md5 3163566688e277f628daf349c1230142 6652B moved-not-cut, giữ file-order gốc — S106 nằm trước S105-close). Digest: S102 CATCH ×2 (reviewer cut-not-moved f229b07 → recover + dead-satellite pointer) · S104-retro self-record blind-spot gate-agent · S105 @start mồ-côi-×1-đóng / @close moved-not-cut byte-level tooling 19380→16305 · S106 ref-table = S98-snapshot benign + cicd-not-spawned-S105 resolved-false-alarm.

  • 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-17→07-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: S98→S101 → 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].
  • 2026-07-11 (S110 @end GATE — self-write diary): GATE PASS 5/5 trục + close-gate. Coverage 5/5: invest S110 H21+MTv3 deep-pass PASS 5-finding [engine: fable-real-single · Fable-S110] (in debe82f) · reviewer :93 PASS_WITH_FIXES 0C/5M CATCH-4 [fable-real-single] · cicd #493 :73 GO 5m24s GOVERNANCE 3-commit + :55 hash-line re-verify (38262d8) · tooling+harvest @start 162f0b9; 3 worker Opus WF wf_0c3b307f-a64 role-less 0-folder đúng chuẩn return-delta. Completeness 4-field đủ cả 3 entry mới. Fidelity khớp việc-thật: verdict khớp commit-msg debe82f "PASS_WITH_FIXES 5M-fixed" · cả 2 Fable-entry tự khai #53-garble→coordinator re-emit in-session recover, diary ghi TRƯỚC re-emit (KHÔNG on-behalf) · #493 timeline khớp 6ee60cd 20:39:15. Corruption: FFFD 0/5 diary · tail 0a 5/5 · 0-byte 0 · 2 gist untouched đúng kỳ-vọng. C5 close-gate: runs/2026-07-11-h21-mtv3-adopt/ run.md 1508B + spec 9372B committed, implement-synthesis.md 3057B non-zero (em-main scribe 21:06) — orphan 15/15 PASS; synthesis UNTRACKED → propose commit closeout-bundle. Method-#6 tái: grep byte-window in <EFBFBD> GIẢ (cắt multibyte) — file FFFD=0, đừng false-alarm. #53 ×2/phiên (invest+reviewer, đều recovered) = garble-rate watch. Chore: SELF ~20K → self-compact S102→S105 phiên tới ĐỨNG. Tag [s110-end-gate, pass-5truc, close-gate-15of15, garble-x2-recovered].
  • 2026-07-12 (S111 @start RE-REPORT — self-write diary): Model claude-fable-5. Verdict 🟢 ALL-CLEAN 5/5 trục (post-S110 closeout 191532e 21:14:52). (1) Harvest-mới 0: porcelain 0 dòng + 12/12 L1 mtime ≤21:13:08 < closeout (method-#3) ⟹ 0 mồ-côi by-construction; S110 landing đủ 3-commit (debe82f invest+reviewer · 38262d8 cicd #493 · 191532e 3-diary-@end + session-log + run-synthesis). (2) Orphan-run 0/15 (run=1·syn_nz=1·syn_z=0 cả 15; run MỚI 2026-07-11-h21-mtv3-adopt FLAT synthesis 3057B đã committed-in-closeout, 0 sub-*.md = return-delta-only by-design, KHÔNG flag). (3) Corruption 0 THẬT: 0-byte 0/12 · tail 0a 12/12 · FFFD 1 hit = entry S110-@end self-quote (method-#6/#9 — literal lần-đầu nằm L1, baseline FFFD=1 từ nay, đừng false-alarm; entry này cố-ý KHÔNG lặp literal; line-ref bỏ vì compact-shift) · mojibake-sig 1 hit = entry S108 self-quote known. (4) Gist ×2 FROZEN byte-exact == HEAD: tooling 6141B · SELF 6544B, diff-lines 0. (5) Fidelity: 5 diary S110 last-touch đúng 3 commit S110, S110-mention {cicd 3·tool 2·self 2·inv 1·rev 1} khớp spawn-set; 7 diary còn lại untouched = not-spawned đúng. Chore→ACTION cùng lượt: hook memory-gate fire (22.2K) → self-compact EXECUTED HOOK-directed, mở-rộng S102→S106 (5 entry 6652B → archive/2026-07.md, block-md5 tại digest-line trên, anchor 5×{L1=0·AR=1}, L1 22160→~16.3K) · impl-be 23955B 93.6% idle từ 06-25 · fe-designer 21.5K · cicd 20.2K · inv-cb 19.7K · reviewer 18.9K > 17.1K watch. Tag [s111-start, all-clean, 0-orphan-0of15, gist-frozen-x2, fffd-baseline-1-selfquote, self-compact-s102-s106-executed].
  • 2026-07-12 (S111 @end GATE — self-write diary): GATE PASS 5/5 trục + close-gate (verify-idempotent, 0 re-APPEND). Coverage 7-spawn: 2 monitor @start 318a271 bundle-4-file · invest-cb +2-line & reviewer +1-line S111 tự-ghi NẰM TRONG 8aa3869 (engine-label [engine: fable-real-single · Fable-S111] cả 2, 0-garble) · cicd ĐANG verify Run 8aa3869 = pending-legit (S111=0 đúng trạng thái, backstop closeout) · tooling @end in-flight song-song (L1 16897B = state-318a271, pattern S107) · 3 worker wf_5ba3daf6-fe0 role-less → memoryDelta vào synthesis đúng run-trace. Close-gate H22 run ĐẦU có sub-*.md: runs/2026-07-12-h22-wal-adopt/ 6/6 file in-8aa3869 (run.md 3298B ## taskList snapshot ×1 chuẩn-MỚI · synthesis 3695B memoryDelta ×1 tail-0a · spec 16220B · sub-task-0/1/2 5737/5478/6172B) — orphan 0/16. Fidelity: reviewer PASS_WITH_FIXES 0C/1M/~7m = 8 finding khớp commit-msg "8/8-fix" · wal-squash K=2 sạch (0 wal: subject trong 191532e..HEAD; 12071c5/67be443 chỉ còn evidence-ref trong msg). Corruption: 0-byte 0/12 · tail 0a 12/12 · FFFD 1 = baseline self-quote · moji 1 known · WAL.md dirty 1372B (< HEAD 1616B) = sổ-WAL live post-squash by-design → flush @closeout, KHÔNG mồ-côi. Method-trap MỚI tự-bắt: --stat truncate .../ nuốt path dài → grep false-absence 5 file run-folder; lọc path PHẢI --name-only. Tag [s111-end-gate, pass-5truc, close-gate-0of16, h22-first-subtask-runtrace, stat-truncate-trap].
  • 2026-07-12 (S113 @start RE-REPORT — self-write diary): Model claude-opus-4-8 (Opus). Verdict 🟡 H2 MOSTLY-CLEAN — 0 orphan/20 · corruption 0 · 2 coverage-gap propose-APPEND (post-S112 closeout 8fa2fcc 16:51; harvest-curator KHÔNG spawn S112 → em-main harvest direct qua 0d912ad+8fa2fcc). (1) Orphan 0/20: 4 S112 folder dùng synthesis EMBEDDED-in-run.md (## synthesis populated — pattern MỚI cho invest/review ensemble, KHÁC h21/h22 separate implement-synthesis.md); 14×06-18 synthesis nằm SUBFOLDER → maxdepth-1 scan FALSE-flag 5 (h10-implement/invest/review + h910-curate/finalize) → maxdepth-2 resolve sep-synth=1 (dual-accept, đừng scan nông). All 4 S112 git-tracked (6/6/4/4, 0 untracked). (2) Harvest 4/6 role CLEAN: inv-cb :20 stamp [engine: fable-clone-ensemble · Opus-S112] 4-field khớp run.md · reviewer ×4 :96-100 (stamp [fable-real-single]) · impl-fe top-🆕 date-labeled (grep-'S112' MISS = method-#4) · cicd :73 #496. (3) 🔴 2 GAP propose-APPEND: impl-be chỉ ghi PE (:77), THIẾU Supplier-BE (SupplierExcelImportService+preview/confirm endpoint+Mig 63 AddSupplierImportSourceFields) — shipped Run #496 nhưng 0 spawn-record nhà mình · test-specialist chỉ bump baseline 440→458 'as of D4' (nên D10/S112), 0 narrative cho ~950 test-LOC (SupplierExcelImportServiceTests +452 NEW / PeSubmitGuardAndBypass +498). Knowledge KHÔNG mất (đủ ở run.md+reviewer+cicd) → propose-only, em-main verify+APPEND B3. (4) Corruption 0: 0-byte 0 · tail 0a 6/6 · FFFD 1 = self-baseline (method-#9). Fidelity 0 fabrication → KHÔNG escalate; minor nit impl-fe '450 tests'(final 458) + test-spec label 'D4'≠'D10'. SELF ~19.2KB > 17.1 target → compact S107→S108 phiên tới. Tag [s113-start, 0-orphan-20, embedded-synthesis-pattern, 2-coverage-gap-implbe-testspec, maxdepth1-false-flag].