Files
solution-erp/.claude/agent-memory/harvest-curator/MEMORY.md
2026-07-12 19:39:33 +07:00

16 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. S107→S109 (5 entry) verbatim → archive/2026-07.md — self-compact 2026-07-12 @S113-end HOOK-directed (plan ĐỨNG từ S107-end/S108; +S109 đạt <17.1KB; block-md5 75b69b41534cb67cdf349b6e1164d47f 5623B moved-not-cut, file-order verbatim). Digest: S107 md5-3of3 all-clean flip-8 · S107-end/S108 GATE PASS 5/5 (od-12th-seed · engine-label-first md5-4of4) · S109-start sleep-resume disk-MATCH + 0-gist-new + self-compact-S98→S101-exec (luot-a-transcript-lost) · S109-sleep-P1 gather 5+5-gist 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].
  • 2026-07-12 (S113 @end GATE — self-write diary, VERIFY-idempotent 0 re-APPEND): Model claude-opus-4-8. GATE PASS 5/5 trục + close-gate 0/21. Coverage 6/6 sub S113 entry đủ 4-field: impl-be :77 (Mig 64 IsPublic+dedup-MST-primary) · impl-fe :9 (FE ×2app, DEVIATION-flag template-btn) · test-spec :59 (458→477 +19, 🔴 BUG NRE null-Code) · reviewer :17 TIERED pointer→project_s113_supplier_import_v2_review.md 3408B (GO-WITH-ADJ 2 must-fix) · cicd :73 🟢 #383/id497 5fa11b5 GO 5m14s · inv-cb :20 ensemble stamp [engine: fable-clone-ensemble · Opus-S113] (em-main harvest, RETURN-only). Landing pattern MỚI: 6 diary committed qua H22 WAL-flush (58f1c5f8304d08 HEAD, KHÔNG closeout ccdcbe7=docs-only H1) — tree clean, 0 uncommitted/mồ-côi. Fidelity MẠNH: 5fa11b5 file-list xác nhận MỌI claim on-disk (Mig 64 3-file · 2 test-file SupplierImportV2Dedup+SupplierPublishAndList · PublishSupplierCommand+GetSupplierImportTemplateQuery NEW · FE 5-file×2app) → 0 fabrication, KHÔNG escalate. S113-start 2 GAP CLOSED (idempotent): impl-be :80 nay có full S112-Supplier entry · test-spec narrative đủ. Close-gate: runs/2026-07-12-S113-supplier-import-v2-invest/ run.md 4202B (embedded=2: ## Synthesis+## OUTCOME) + spec 12900B, cả 2 tracked; orphan 0/21 (14×06-18 sep-synth · h21/h22 sep · 4 S112 embed=1 · S113 embed=2). Corruption 0: 0-byte 0 · tail 0a 8/8 · FFFD 0/8 (S113-touched files) · moji 0. Nit ×2 benign (INFORM, 0 data-loss, KHÔNG escalate): (a) inv-cb entry trỏ "journal.jsonl" NHƯNG folder RETURN-only 0 jsonl/sub-*.md — content THẬT ở run.md Synthesis/OUTCOME+spec → propose sửa pointer · (b) impl-be "backfill 22 prod" stale-est, thật 37 (cicd+inv+run.md reconcile 37/37, all-rows UPDATE→moot). Chore: inv-cb 21.6KB cao nhất (em-main defer-curate next-session per plan, KHÔNG miss) · reviewer 20.3 · cicd 19.9 · impl-be 19.8 · SELF 19.3 → self-compact S107→S108 phiên tới ĐỨNG; all < 25.6 cap. Tag [s113-end-gate, pass-5truc, close-gate-0of21, wal-flush-landing, 2gap-closed, journal-jsonl-deadpointer-nit].