# script-arm @bookend-close S185 — SAU-harvest (f-bis re-measure)

## 1. measure-agent-memory (f-bis — số SAU-append)
{
    "measured_at_note":  "run date stamped by caller (Date.now unavailable in workflow scripts)",
    "soft_cap_l1_bytes":  30720,
    "autoinject_cap_bytes":  25600,
    "agents":  [
                   {
                       "agent":  "back-end-reviewer-style",
                       "l1_hot_bytes":  3908,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "cicd-monitor",
                       "l1_hot_bytes":  23798,
                       "l2_verbatim_bytes":  264257,
                       "l2_index_bytes":  23588,
                       "l2_gist_bytes":  122471,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "ctx-audit",
                       "l1_hot_bytes":  24924,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "ctx-curator",
                       "l1_hot_bytes":  13340,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "ctx-verifier",
                       "l1_hot_bytes":  19205,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "database-agent",
                       "l1_hot_bytes":  9038,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "database-reviewer-style",
                       "l1_hot_bytes":  4376,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "frontend-designer",
                       "l1_hot_bytes":  19869,
                       "l2_verbatim_bytes":  19050,
                       "l2_index_bytes":  2435,
                       "l2_gist_bytes":  3231,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "front-end-reviewer-style",
                       "l1_hot_bytes":  3857,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "harness-audit",
                       "l1_hot_bytes":  16622,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "harness-eval",
                       "l1_hot_bytes":  15469,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "harness-refine",
                       "l1_hot_bytes":  15126,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "harvest-curator",
                       "l1_hot_bytes":  28071,
                       "l2_verbatim_bytes":  78576,
                       "l2_index_bytes":  8325,
                       "l2_gist_bytes":  20317,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "implementer-backend",
                       "l1_hot_bytes":  25515,
                       "l2_verbatim_bytes":  86134,
                       "l2_index_bytes":  10487,
                       "l2_gist_bytes":  84345,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "implementer-frontend",
                       "l1_hot_bytes":  16441,
                       "l2_verbatim_bytes":  47796,
                       "l2_index_bytes":  5844,
                       "l2_gist_bytes":  44764,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "investigator-api",
                       "l1_hot_bytes":  9021,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "investigator-codebase",
                       "l1_hot_bytes":  18199,
                       "l2_verbatim_bytes":  171476,
                       "l2_index_bytes":  12448,
                       "l2_gist_bytes":  107741,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "lead-gap-auditor",
                       "l1_hot_bytes":  24241,
                       "l2_verbatim_bytes":  22645,
                       "l2_index_bytes":  1234,
                       "l2_gist_bytes":  7112,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "lead-stale-auditor",
                       "l1_hot_bytes":  30852,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  true
                   },
                   {
                       "agent":  "office-document",
                       "l1_hot_bytes":  3323,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "reviewer",
                       "l1_hot_bytes":  31341,
                       "l2_verbatim_bytes":  243035,
                       "l2_index_bytes":  13941,
                       "l2_gist_bytes":  69925,
                       "l1_over_30kb":  true
                   },
                   {
                       "agent":  "ring1-audit",
                       "l1_hot_bytes":  23874,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "ring2-audit",
                       "l1_hot_bytes":  31781,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  true
                   },
                   {
                       "agent":  "ring4-audit",
                       "l1_hot_bytes":  3349,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "score-count-auditor",
                       "l1_hot_bytes":  2330,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "score-counter",
                       "l1_hot_bytes":  2366,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "test-specialist",
                       "l1_hot_bytes":  18914,
                       "l2_verbatim_bytes":  37615,
                       "l2_index_bytes":  6170,
                       "l2_gist_bytes":  33811,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "tooling-auditor",
                       "l1_hot_bytes":  30981,
                       "l2_verbatim_bytes":  72498,
                       "l2_index_bytes":  3672,
                       "l2_gist_bytes":  18760,
                       "l1_over_30kb":  true
                   }
               ]
}

## 2. mfe-eval

=== MFE (Memory-Fidelity-EVAL) - Harness-16 - 2026-08-09 ===
    (coverage/retention eval; NOT memoryDelta-routing-fidelity H6.7)
    lead hot-feed cap (live) = 380000 tok | mem-sub cap = 60000 tok

[LEAD] must-remember denominator (deduped, merge_guard_to_as=True):
   marks(Active+High)=11  AS-classes=15  net-extra-guards=5  net-extra-recurring-gotchas=7
   => DENOMINATOR = 38 items  (raw before dedup: marks 11 + AS 15 + guards 16 + recurring 8)

[LEAD] Coverage-FIT (does the set FIT the hot-feed cap?):
   span bytes=30945  =>  ~7736 - 10315 tok (RANGE, see caveat)  /  cap 380000 tok  =  2.71% worst-case
   FIT = PASS (worst-case fits; headroom huge - must-remember set is tiny vs cap)
   CAVEAT: char/4 is NOT real tokens; VN-diacritic ~3.0-3.5 byte/tok => byte/4 = upper-bound headroom.
           Reported as a RANGE [bytes/4 .. bytes/3.0]; FIT uses bytes/3.0 (worst). Real count inside the band.

[LEAD] age-band (FLAG only - age=false-proxy, mark RC-...10-29-11):
   marks with parseable date=11; >30d old but still Active=4 -> KEPT (status-driven, age-blind)
   (guards/gotchas carry session-refs not dates -> age = status-driven only; drop on status-change, never by age)

[LEAD] Goodhart anchor (NO self-grading - real recurring-error signal):
   error-ledger: strikes_total=25  RCA_entries=16  AS-classes=15
   (rule: if strikes rise across runs while coverage stays high -> the score lies. warn-baseline=25 last_run_strikes=25)

[SUB] per-role memory coverage (denominator = role-file anti-patterns/baseline; numerator = carried in diary):
   match = exact-id OR >=2 distinct content-words after stop-list (leading-verb-only = false-max, defeated)

   back-end-reviewer-style N/A (no numbered anti-pattern / NEVER block in role-file to extract)
   cicd-monitor            10/10  = 100% (MEASURED, not target-then-force)
   ctx-audit               10/10  = 100% (MEASURED, not target-then-force)
   ctx-curator              6/6   = 100% (MEASURED, not target-then-force)
   ctx-verifier             7/7   = 100% (MEASURED, not target-then-force)
   database-agent           7/7   = 100% (MEASURED, not target-then-force)
   database-reviewer-style N/A (no numbered anti-pattern / NEVER block in role-file to extract)
   front-end-reviewer-style N/A (no numbered anti-pattern / NEVER block in role-file to extract)
   frontend-designer        2/2   = 100% (MEASURED, not target-then-force)
   harness-audit            5/5   = 100% (MEASURED, not target-then-force)
   harness-eval             5/5   = 100% (MEASURED, not target-then-force)
   harness-refine           5/5   = 100% (MEASURED, not target-then-force)
   harvest-curator          7/7   = 100% (MEASURED, not target-then-force)
   implementer-backend     18/18  = 100% (MEASURED, not target-then-force)
   implementer-frontend    12/13  =  92% (MEASURED, not target-then-force)
   investigator-api         7/7   = 100% (MEASURED, not target-then-force)
   investigator-codebase    8/8   = 100% (MEASURED, not target-then-force)
   lead-gap-auditor         6/6   = 100% (MEASURED, not target-then-force)
   lead-stale-auditor       6/6   = 100% (MEASURED, not target-then-force)
   office-document          6/6   = 100% (MEASURED, not target-then-force)
   reviewer                 8/8   = 100% (MEASURED, not target-then-force)
   ring1-audit              5/5   = 100% (MEASURED, not target-then-force)
   ring2-audit              5/5   = 100% (MEASURED, not target-then-force)
   ring4-audit              5/5   = 100% (MEASURED, not target-then-force)
   score-count-auditor    N/A (no numbered anti-pattern / NEVER block in role-file to extract)
   score-counter          N/A (no numbered anti-pattern / NEVER block in role-file to extract)
   test-specialist          6/6   = 100% (MEASURED, not target-then-force)
   tooling-auditor          8/8   = 100% (MEASURED, not target-then-force)

[SUB-WORKFLOW] N/A by design: fan-out workflow agents (hmw.js sub-<role>-<i>) are EPHEMERAL
   (no persistent diary; their only memory channel is the lead-injected memory-pack -> source-vs-cap is meaningless).

=== MFE done (deterministic block; READ-ONLY on budget; exit 0) ===

## 3. memory-archive-gate DRY
============================================================
 memory-archive-gate.ps1  -  Harness-11 PART-A
 mode        : DRY-RUN (no writes at all)
 cap         : 25600 bytes (autoinject_cap)
 low-water   : 21760 bytes (A4 hysteresis drain target = ratio 0.85)
 keep-floor  : 5 newest entries (A5)
 strike-need : 2 consecutive over-cap runs to PROPOSE (A6)
============================================================

### PASS 1 - hot-tier over-cap planner (FLAG ONLY, no moves)

sub                          bytes over?    entries  strike    after-est resolve
------------------------ --------- ----- ---------- ------- ------------ -------
back-end-reviewer-style       3908    no          0       0            - ok
cicd-monitor                 23798    no         19       0            - ok
ctx-audit                    24924    no          3       0            - ok
ctx-curator                  13340    no          0       0            - ok
ctx-verifier                 19205    no          2       0            - ok
database-agent                9038    no          6       0            - ok
database-reviewer-style       4376    no          0       0            - ok
frontend-designer            19869    no          7       0            - ok
front-end-reviewer-style      3857    no          0       0            - ok
harness-audit                16622    no          7       0            - ok
harness-eval                 15469    no          7       0            - ok
harness-refine               15126    no          7       0            - ok
harvest-curator              28071   YES          9       1       ~27224 WARN value-floor hit: over-cap but every drainable entry is value-protected/keep-floor - condense high-value BY HAND (do NOT age-archive)
    [D3 value-gate] 5 value-protected logical entr(y/ies) HARD-SKIPPED from the drain set (kept regardless of position/age); move-set = lowest-value only. NOTE: 9-token grep = lower-bound; em-main must value-scan the WHOLE proposed set (paraphrase/spine leak remains).
implementer-backend          25515    no         24       0            - ok
implementer-frontend         16441    no         11       0            - ok
investigator-api              9021    no         10       0            - ok
investigator-codebase        18199    no         10       0            - ok
lead-gap-auditor             24241    no          7       0            - ok
lead-stale-auditor           30852   YES          6       1       ~30214 WARN keep-floor hit (5); cannot auto-drain - SPLIT/condense entries by hand
    [D3 value-gate] 1 value-protected logical entr(y/ies) HARD-SKIPPED from the drain set (kept regardless of position/age); move-set = lowest-value only. NOTE: 9-token grep = lower-bound; em-main must value-scan the WHOLE proposed set (paraphrase/spine leak remains).
office-document               3323    no          3       0            - ok
reviewer                     31341   YES          8       1       ~30982 WARN value-floor hit: over-cap but every drainable entry is value-protected/keep-floor - condense high-value BY HAND (do NOT age-archive)
    [D3 value-gate] 5 value-protected logical entr(y/ies) HARD-SKIPPED from the drain set (kept regardless of position/age); move-set = lowest-value only. NOTE: 9-token grep = lower-bound; em-main must value-scan the WHOLE proposed set (paraphrase/spine leak remains).
ring1-audit                  23874    no          6       0            - ok
ring2-audit                  31781   YES          7       2       ~23102 PROPOSE archive (strike 2>=2): move 2 lowest-value (position tiebreak) -> curate L1->L2 by hand
    [D3 value-gate] 1 value-protected logical entr(y/ies) HARD-SKIPPED from the drain set (kept regardless of position/age); move-set = lowest-value only. NOTE: 9-token grep = lower-bound; em-main must value-scan the WHOLE proposed set (paraphrase/spine leak remains).
ring4-audit                   3349    no          2       0            - ok
score-count-auditor           2330    no          0       0            - ok
score-counter                 2366    no          0       0            - ok
test-specialist              18914    no          7       0            - ok
tooling-auditor              30981   YES         11       1       ~30134 WARN value-floor hit: over-cap but every drainable entry is value-protected/keep-floor - condense high-value BY HAND (do NOT age-archive)
    [D3 value-gate] 4 value-protected logical entr(y/ies) HARD-SKIPPED from the drain set (kept regardless of position/age); move-set = lowest-value only. NOTE: 9-token grep = lower-bound; em-main must value-scan the WHOLE proposed set (paraphrase/spine leak remains).

  [A6] DRY-RUN: strike counters NOT persisted (run with -Apply to advance strikes)

### PASS 2 - A7 archive-integrity gate (NO-API: grep + measure only)

  [cicd-monitor] _INDEX.md + 14 archive file(s)
    -> PASS  pointers 112  resolved 112  failed 0
  [frontend-designer] _INDEX.md + 2 archive file(s)
    -> PASS  pointers 9  resolved 9  failed 0
  [harvest-curator] _INDEX.md + 4 archive file(s)
    -> PASS  pointers 48  resolved 48  failed 0
  [implementer-backend] _INDEX.md + 13 archive file(s)
    -> PASS  pointers 43  resolved 43  failed 0
  [implementer-frontend] _INDEX.md + 4 archive file(s)
    -> PASS  pointers 44  resolved 44  failed 0
  [investigator-codebase] _INDEX.md + 14 archive file(s)
    -> PASS  pointers 56  resolved 56  failed 0
  [lead-gap-auditor] _INDEX.md + 2 archive file(s)
    -> PASS  pointers 7  resolved 7  failed 0
  [reviewer] _INDEX.md + 10 archive file(s)
    -> PASS  pointers 57  resolved 57  failed 0
  [test-specialist] _INDEX.md + 4 archive file(s)
    -> PASS  pointers 33  resolved 33  failed 0
  [tooling-auditor] _INDEX.md + 4 archive file(s)
    -> PASS  pointers 20  resolved 20  failed 0

------------------------------------------------------------
 A7 GATE PASS  -  total pointers 429, resolved 429, failed 0
------------------------------------------------------------

## 4. crystallized-backfill
============================================================
 crystallized-backfill.ps1  -  measure-then-fill (DRY planner)
 tier        : lead
 budget.json : D:\Dropbox\CONG_VIEC\SOLUTION\SOLUTION_ERP\.claude\agent-memory\memory-budget.json
 cb config   : present (target + hotload_sources read LIVE)
============================================================

### hot-load sources (LIVE byte-measure, UTF8)

source                                            bytes    state
-------------------------------------------- ---------- --------
docs/STATUS.md                                   234644       ok
docs/HANDOFF.md                                  196350       ok
.claude/governance/ACTIVE-MARKS.md                36153       ok
docs/changelog/migration-todos.md                 88151       ok
docs/gotchas.md                                  120260       ok
.claude/agents/README.md                          60723       ok
TOTAL                                            736281         

### budget numbers (Upgrade-1) - ALL live-read, 0 hardcoded

Tran tong (live cap)   : 380000 tok
hotload measured       : 736281 bytes
tok RANGE [low..high]  : [184070 .. 245427] tok  (bytes/4 .. bytes/3.0)
measured_headroom      : 134573 tok  (cap - tok_high, worst-case)
target (owner)         : 210000 tok
expected_backfill      : 134573 tok  (min(target,headroom)=headroom => headroom binds (target exceeds room))

### value-gated backfill source-order (planner / DRY - no pour)

  precondition MET (target>0 AND headroom>0): would pull up to 134573 tok in order:
    1. gist            → archive/*.gist.md (4-field distilled)
    2. value-marked    → archive lines carrying gotcha# / anti-pattern / root-cause
    3. curated RAG     → search_memory high-value hits
    (each stage DEDUP vs the hot-load sources above; stop at expected_backfill)

------------------------------------------------------------
 HONEST CAVEAT
   char/4 is NOT a real token count; VN-diacritic hot-memory ~3.0-3.5 byte/tok.
   Headroom is a RANGE [bytes/4 .. bytes/3.0]; this planner uses bytes/3.0 (worst).
   backfill defaults to 0 = TAT until the OWNER sets target>0 AND measured headroom>0.
   Every budget number is the OWNER's authority; this script is READ-ONLY (never tunes/writes).
   HEADROOM is measured over a STABLE FILE-FLOOR (the configured hotload_sources) = an UPPER BOUND.
   The PEAK hot-feed also loads session-variable task-context NOT in this list; real headroom is SMALLER.
------------------------------------------------------------

## 5. nhip-no-probe
NHIP-NO: kiem light 3/6 deep 19/15 OVERDUE:deep | tran-bo-nho 5 over-cap l2idx 0 over | run-chua-gom 1 | pull-cach 4 ngay | so-yc treo 5 / nhac2+ 2 (muc 13, gop 5 dong nhac-lai)
