16 KiB
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 RAGsearch_memoryjust-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 (H11memory-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). 🧊 Ledgerruns/_ledger.mdRETIRED 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.mdmà*-synthesis.mdVẮ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.mdPhase 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)
- Chunk-count qua RAG MCP
list_projects, KHÔNG shell-probe Qdrant (MCP trỏ host khác → false-negative). - Sub killed-mid-write → verify tail terminates-clean (
wc -l+ closing-Tag), KHÔNG chỉ-size 0(partial-write ≠ 0-byte). - Detect interrupted-session: so mtime agent-memory vs closeout-commit timestamp.
- Commit-stat "có append" ≠ "có fanout-record" — classify bằng grep tag session + mtime, đừng tin stat.
- Extract added-bullet trong diff:
grep "^+-"(filtergrep -v "^[+-][+-]"NUỐT dòng+- **…). tail -c Ncắ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).- Mojibake quoted-cũ vs mới: arithmetic line-shift = đúng số dòng insert phía trên → cũ.
- Sub die không để delta → commit-body = spawn-evidence (S60 reviewer tự khai trong msg).
- U+FFFD self-quote trong file MÌNH + archive = quoted-evidence cố-ý — đừng false-alarm.
- 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-md5e2b906336b4cdad3034329cffc09525amoved-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-md53163566688e277f628daf349c12301426652B moved-not-cut, giữ file-order gốc — S106 nằm trước S105-close). Digest: S102 CATCH ×2 (reviewer cut-not-movedf229b07→ 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-md575b69b41534cb67cdf349b6e1164d47f5623B 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. S110→S111 (4 entry) verbatim →archive/2026-07.md— self-compact 2026-07-13 @S116-end HOOK-directed (SELF 20KB>read-limit; plan ĐỨNG từ S114-start; block-md5640f80e452b42badb12bc2a3c57cf9f76638B moved-not-cut, file-order verbatim, anchor 4×{L1=0·AR=1}). Digest: S110-start rerun-DEDUP luot-sang-transcript-lost (gist byte-exactcat-file==disk) · S110-end GATE PASS 5/5 close-gate-15of15 garble-x2-recovered + FFFD-baseline-1-selfquote seed · S111-start self-compact-S102→S106-EXECUTED + gist-frozen-x2 · S111-end GATE PASS 5/5 close-gate-0of16 h22-first-subtask-runtrace +--stat-truncate-trap. S113 ×2 entry (start+end) verbatim →archive/2026-07.md— self-compact 2026-07-14 @S118-start (plan ĐỨNG từ S117-end soft-due; block-md50c782c7cebc8f1d8b16f65b8e14748204064B moved-not-cut, file-order verbatim, anchor 2×{L1=0·AR=1}). Digest: S113-start MOSTLY-CLEAN 0-orphan/20 + 2-coverage-gap propose (impl-be thiếu Supplier-BE · test-spec thiếu narrative; embedded-synth pattern mới · maxdepth-1 false-flag lesson) · S113-end GATE PASS 5/5 0/21 (2-gap CLOSED idempotent · wal-flush-landing 6-diary · Fidelity5fa11b5file-list exact · nit journal-jsonl dead-pointer + backfill-22-vs-37).
- 2026-07-12 (S114 @start RE-REPORT — self-write diary, VERIFY-idempotent 0 re-APPEND): Model
claude-opus-4-8(Opus). Verdict 🟢 ALL-CLEAN 5/5 trục + 0/21 orphan (post-S113 final wal-flusha3e9e1419:39:33; S113 harvest ĐÃ HOÀN-TẤT @S113-end, đây = re-verify sau flush cuối). (1) Harvest-mới 0: porcelain 0 dòng + 12/12 L1 mtime ≤19:36:52 <a3e9e14(method-#3) ⟹ 0 mồ-côi by-construction; post-end DUY-NHẤT 1 commit =a3e9e14chạm CHỈ diary SELF (S113@end-entry + self-compact). (2) Orphan 0/21 (embedded-synth re-scan sau khi tự-bắt-cl-bug false-flag: 4 S112 embed=1## synthesis· S113 embed=2## Synthesis+## OUTCOME· 14×06-18 sep-synth · h21/h22 sep). (3) Coverage 6/6 sub S113 landed đủ 4-field (impl-be:77·impl-fe:9·test-spec:59·reviewer:17-TIERED·cicd:73·inv-cb:20-ensemble); #53-garble ×2 CẢ HAI captured (inv-cb:23 visibility-lane em-solo-recover + impl-be:77 backend-first-return SendMessage-resume); 4-BUG captured đúng nhà (NRE-null-Code#80 test-spec:59 · draft-leak+CreateSupplier-IsPublic reviewer:17 · authz-403→D3 role→policy-fix impl-be:77); S113-start 2-GAP STAY-CLOSED (impl-be:80 S112-Supplier entry + test-spec narrative). (4) Corruption 0: 0-byte 0/12 · tail0a12/12 · FFFD 1 = SELF-baseline self-quote (method-#9). (5) Self-compact S107→S109 @S113-end (a3e9e14) moved-not-cut VERIFIED (5 anchor L1=0/AR=1; S108-GATE L1=1 = digest-line mention đúng; archive 18390B tail-0a). 2 KNOWN benign nit persist (em-main chưa fix, 0-data-loss, INFORM KHÔNG escalate): inv-cb:21 "journal.jsonl" dead-pointer (folder RETURN-only 0-jsonl, content THẬT @run.md-synth+narrative:20-25) · impl-be:77 "backfill 22 prod" stale-est (thật 37,UPDATE SET IsPublic=1all-rows→moot). Self-inconsistency benign: S113@end body ghi "compact deferred" nhưng digest+diff = EXECUTED HOOK-directed (pattern S111). Chore: inv-cb 21.6K cao nhất · reviewer 20.8 · cicd 20.4 · impl-be 20.2 · SELF 16.8K post-compact healthy → self-compact S110→S111 phiên tới; all < 25.6 cap. Tag[s114-start, all-clean, 0-orphan-0of21, verify-idempotent, garble-x2-captured, 4bug-captured, self-compact-s107-s109-moved-not-cut]. - 2026-07-13 (S116 @end GATE — self-write diary, VERIFY-idempotent 0 re-APPEND): Model
claude-opus-4-8. GATE PASS 5-trục + close-gate 0/24 (PE nhập giá ÂM ô báo giá, shipped88368fd+ CI #386; HEAD0edbc58wal-flush-landing, tree clean). Coverage 🟡 5/6 role-bucket đủ (1 sub-gap): 3 impl self-write đủ 4-field (impl-fe :9-15 sign-toggle-immediate-commitmath.abs-no-global-mod SHA3e16dba5×2 + gotchadetails[].quotes≠suppliers[]· impl-be :77 guard-1line ACCEPT + stale-comment-flag · test-spec :59 486→495 +9 T1-T4) + cicd :79 #386 GO 5m28s; invest-ensemble 4-lane RETURN-only em-main consolidated 4→2 (:78 Budget-consumers + :97 edge/precedent, FE+BE-surface embedded, knowledge-complete); review-ensemble 3-lane RETURN-only → Lane1 correctness-wire :21 TIERED-pointer (project_pe_negative_quote_correctness_review.md2908B EXISTS not-dead) + Lane3 financial-invariant :77 — NHƯNG Lane2 mirror-completeness KHÔNG có spawn-record riêng (knowledge NOT-lost: run.md:11 'mirror clean' + correctness-pointer + invest:97 SHA-identical + impl-fe SHA-pair) → propose em-main APPEND minimal Lane2. fable-real deep-pass #53-GARBLE 0-verdict → em-main-solo gate (run.md:13), nothing-to-harvest. Fidelity STRONG 0-fab → KHÔNG escalate:88368fd= 7-file EXACT (2FE+1BE+4test no-mig) · BESum()<=0→.All(x==0)verbatim in-diff · 9 new[Fact]/[Theory]= +9 = gate 495. Corruption 0: 0-byte 0 · tail 0a 7/7 · FFFD 0 worker (self=1 baseline #9) · cicd:58$(cygpath)= intentional-cmd-example không shell-baked · moved-not-cut ×2 VERIFIED (reviewer→2026-07 3-anchor · impl-be FIFO→2026-06 5-anchor). Close-gate: run.md embedded-synth✅ PIPELINE COMPLETE:19 + run.md/spec git-tracked HEAD; orphan 0/24 (14×06-18 sep · h21/h22/presence sep · 4×S112+S113emb2+S114+S116 embedded). method-#10 DOUBLE session-drift-tag S116 (cả 2 = em-main ON-BEHALF harvest, self-write all-correct-S116): reviewer:77 labelS117-forward + invest:78 tag[s115?]-backward → mislabel clusters tại on-behalf-harvest → propose normalize→S116. Nit: run.md:20-23 leftover template[ ]rows dup completed Stages4-6 (benign residue, propose trim). Chore: fe-designer 21.5K idle-07-01 · invest-cb 21.1 · impl-fe 21.1 · cicd 20.4 · reviewer 19.2 (post-curate + re-append) · SELF 19.1→~21K → self-compact S110→S111 STILL-DUE phiên tới; all < 25.6 cap. Tag[s116-end-gate, pass-5truc, close-gate-0of24, review-lane2-mirror-gap, double-session-drift-tag-m10, fidelity-strong-7file-exact]. - 2026-07-14 (S117 @end GATE — self-write diary, VERIFY-idempotent 0 re-APPEND): Model
claude-opus-4-8. GATE PASS 5-trục + close-gate 0-orphan (2 chỉnh PE UAT anh Kiệt: lũy-kế display-lie fix + duyệt-theo-khoảng Min–Max ProMinMax, shipped316a82f+ CI #387 501-gate; HEADfc1b8d9closeout tree-clean). Coverage 5/5 spawn (inv×2 share investigator-codebase/ + test-spec + impl-fe + cicd): inv-luyke :107[fable-real-single·Fable-S117]wf ab2657ee (#53-garble→resume + em-main prod-DB verify) · inv-minmax :104 wf abbbb86d 0-garble Model-A · test-spec :59 +5 ProMinMax · impl-fe :9[s117]SHA 011ee8cf/617b0aa0 · cicd :41/59/60/61 #387. BE both-features = em-main-solo by-design (financial signature-ripple) → 0 impl-backend record expected (KHÔNG gap). Fidelity STRONG 0-fab → KHÔNG escalate: commit316a82ffile-list EXACT match mọi claim (Mig 66 3-fileApprovedPriceMaxAmount+ entity+9 + service+34 + 6 FE 3/app symmetric + 2 test-file); STATUS 501; Mig 66 COL_LENGTH=9 prod; 2 garble-lane (invest-1+cicd) 0 claim-bịa (em-main-curl cross-verify khớp). Corruption 0: tail 0a 6/6 · FFFD 0 · impl-fe compact 23.3→13.3KB MOVED-NOT-CUT VERIFIED (archive/2026-H1.md +5 entry verbatim, 6/6 SHA-anchor; HOT S117/S116/S113 giữ) · cicd:58$(cygpath)intentional-cmd. Close-gate: 2 /fable-real folder spec-*.md present+tracked (luyke 5828B/minmax 4202B, dual-accept ≠ hmw-synthesis); 0 orphan (no run.md-sans-synth); delta mồ-côi 0 (4 memory WAL-committed 11:00–11:29, porcelain clean). 3 benign nit INFORM (0 data-loss, KHÔNG escalate): (a) inv-minmax mis-tag S118→S117 (method-#10 drift fwd-1; content+spec đều S117) · (b) test-spec baseline 500/455→501/456 (thiếu em-main-solo +1 luykePeFinalizeProjectionTests; đếm own +5 only) · (c) cicd:17 self-claim "S117 CLEAN no-garble ×3" vs session-log+task = garble-then-resume (under-report own garble; verdict-substance disk-true). Chore: 0 memory >25.6 cap (cicd 19.8/inv-cb 19.6 max); impl-fe healthy 13.3 post-compact; SELF 15.6→~17.2K → self-compact S113 phiên tới soft-due. Tag[s117-end-gate, pass-5truc, close-gate-0orphan-fable-real-spec, moved-not-cut-verified, 3nit-s118mistag-testcount500-cicdgarbleclaim, fidelity-strong-commit-exact]. - 2026-07-14 (S118 @start RE-REPORT — self-write diary, VERIFY-idempotent 0 re-APPEND): Model
claude-fable-5. Verdict 🟢 ALL-CLEAN — 0 harvest-mới · 0 orphan/26 · 0 delta mồ-côi · corruption 0 · 3-nit-S117 ALL-FIXED. Post-S117-gate đúng 2 commit chạm memory, cả 2 accounted:1b8b065(em-main reconcile 3 diary = đóng trọn 3 benign-nit INFORM @S117-end, diff-verified: (a) inv-cb## S118→## S117· (b) test-spec 500/455→501/456 + nguồn +1 em-main-soloPeFinalizeProjectionTests· (c) cicd "no-garble ×3"→"×2; S117 garble→SendMessage-resume verdict-substance OK") +5c7569efinal-flush (+1 dòng = chính S117@end-entry SELF). Porcelain 0 + 12/12 L1 mtime ≤ 11:56:15 ⟹ 0 mồ-côi by-construction (method-#3). Orphan 0/26 dual-accept: 14×06-18 (5 sub-synth maxdepth-2 + 9 flat) · 3 flat Jul (h21/h22/presence) · 6 embedded (4×S112+S113+S114) · pe-negative-quote embedded NON-heading✅ PIPELINE COMPLETE:19 (regex^## synthesisMISS → verify-trực-tiếp trước flag, đừng tin heading-scan đơn thuần) · 2×S117 fable-real spec-only KHÔNG run.md (spec 5828B/4202B tracked) = by-design ≠ orphan. Corruption 0: 0-byte 0/12 · tail 0a 8/8 touched · FFFD 0/12 — SELF-baseline FFFD 1→0 (entry chứa self-quote đã rời L1 qua archive, sạch hơn không phải mất; cập nhật baseline method-#9). Chore: 0 L1 > 25.6 cap (fe-designer 21.5K idle-07-01 · cicd 19.96 · inv-cb 19.6); SELF ~19.3K > 17.1 target → self-compact S113-block DUE phiên này (plan đứng từ S117-end). Delta cần APPEND: 0. Tag[s118-start, all-clean, 0-orphan-0of26, 3nit-all-fixed-1b8b065, embedded-nonheading-pipeline-complete, fffd-baseline-1to0].