# instruments @S151 (lead-run truoc trio - script-arm in SO, eval DOC + so-baseline)

## 1. measure-agent-memory.ps1
{
    "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":  "cicd-monitor",
                       "l1_hot_bytes":  19281,
                       "l2_verbatim_bytes":  228990,
                       "l2_index_bytes":  22634,
                       "l2_gist_bytes":  40303,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "database-agent",
                       "l1_hot_bytes":  7388,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "frontend-designer",
                       "l1_hot_bytes":  21492,
                       "l2_verbatim_bytes":  6624,
                       "l2_index_bytes":  1531,
                       "l2_gist_bytes":  3231,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "harness-audit",
                       "l1_hot_bytes":  1513,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "harness-eval",
                       "l1_hot_bytes":  1547,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "harness-refine",
                       "l1_hot_bytes":  1611,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "harvest-curator",
                       "l1_hot_bytes":  20933,
                       "l2_verbatim_bytes":  67374,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  20317,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "implementer-backend",
                       "l1_hot_bytes":  19449,
                       "l2_verbatim_bytes":  75787,
                       "l2_index_bytes":  10105,
                       "l2_gist_bytes":  23079,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "implementer-frontend",
                       "l1_hot_bytes":  15951,
                       "l2_verbatim_bytes":  25581,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  11125,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "investigator-api",
                       "l1_hot_bytes":  8510,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "investigator-codebase",
                       "l1_hot_bytes":  10596,
                       "l2_verbatim_bytes":  147348,
                       "l2_index_bytes":  12384,
                       "l2_gist_bytes":  43854,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "lead-gap-auditor",
                       "l1_hot_bytes":  24185,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "lead-stale-auditor",
                       "l1_hot_bytes":  10128,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "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":  18047,
                       "l2_verbatim_bytes":  155039,
                       "l2_index_bytes":  13780,
                       "l2_gist_bytes":  35098,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "ring1-audit",
                       "l1_hot_bytes":  4481,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "ring2-audit",
                       "l1_hot_bytes":  9840,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "ring4-audit",
                       "l1_hot_bytes":  1047,
                       "l2_verbatim_bytes":  0,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  0,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "test-specialist",
                       "l1_hot_bytes":  22140,
                       "l2_verbatim_bytes":  18065,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  5374,
                       "l1_over_30kb":  false
                   },
                   {
                       "agent":  "tooling-auditor",
                       "l1_hot_bytes":  20082,
                       "l2_verbatim_bytes":  66747,
                       "l2_index_bytes":  0,
                       "l2_gist_bytes":  18760,
                       "l1_over_30kb":  false
                   }
               ]
}

## 2. mfe-eval.ps1

=== MFE (Memory-Fidelity-EVAL) - Harness-16 - 2026-07-25 ===
    (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)=9  AS-classes=15  net-extra-guards=5  net-extra-recurring-gotchas=7
   => DENOMINATOR = 36 items  (raw before dedup: marks 9 + AS 15 + guards 15 + recurring 8)

[LEAD] Coverage-FIT (does the set FIT the hot-feed cap?):
   span bytes=28191  =>  ~7048 - 9397 tok (RANGE, see caveat)  /  cap 380000 tok  =  2.47% 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=9; >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=23  RCA_entries=14  AS-classes=15
   (rule: if strikes rise across runs while coverage stays high -> the score lies. last_run_strikes=23)

[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)

   cicd-monitor            10/10  = 100% (MEASURED, not target-then-force)
   database-agent         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        N/A (no numbered anti-pattern / NEVER block in role-file to extract)
   implementer-backend     17/18  =  94% (MEASURED, not target-then-force)
   implementer-frontend    11/13  =  85% (MEASURED, not target-then-force)
   investigator-api         6/7   =  86% (MEASURED, not target-then-force)
   investigator-codebase    7/8   =  88% (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        N/A (no numbered anti-pattern / NEVER block in role-file to extract)
   reviewer                 7/8   =  88% (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)
   test-specialist          6/6   = 100% (MEASURED, not target-then-force)
   tooling-auditor        N/A (no numbered anti-pattern / NEVER block in role-file to extract)

[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.ps1 (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
------------------------ --------- ----- ---------- ------- ------------ -------
cicd-monitor                 19281    no         20       0            - ok
database-agent                7388    no          6       0            - ok
frontend-designer            21492    no          7       0            - ok
harness-audit                 1513    no          4       0            - ok
harness-eval                  1547    no          4       0            - ok
harness-refine                1611    no          4       0            - ok
harvest-curator              20933    no          7       0            - ok
implementer-backend          19449    no         23       0            - ok
implementer-frontend         15951    no         19       0            - ok
investigator-api              8510    no          9       0            - ok
investigator-codebase        10596    no         11       0            - ok
lead-gap-auditor             24185    no          9       0            - ok
lead-stale-auditor           10128    no          2       0            - ok
office-document               3323    no          3       0            - ok
reviewer                     18047    no         16       0            - ok
ring1-audit                   4481    no          3       0            - ok
ring2-audit                   9840    no          3       0            - ok
ring4-audit                   1047    no          1       0            - ok
test-specialist              22140    no         17       0            - ok
tooling-auditor              20082    no          8       0            - ok

  (no sub over cap - hot tier within auto-inject budget)

  [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 + 9 archive file(s)
    -> PASS  pointers 101  resolved 101  failed 0
  [frontend-designer] _INDEX.md + 2 archive file(s)
    -> PASS  pointers 0  resolved 0  failed 0
  [implementer-backend] _INDEX.md + 7 archive file(s)
    -> PASS  pointers 41  resolved 41  failed 0
  [investigator-codebase] _INDEX.md + 9 archive file(s)
    -> PASS  pointers 55  resolved 55  failed 0
  [reviewer] _INDEX.md + 7 archive file(s)
    -> PASS  pointers 56  resolved 56  failed 0

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

## 4. tham-chieu output phien nay (da chay o bootstrap)
NHIP-NO: kiem light 1/6 deep 8/15 ok | tran-bo-nho 0 over-cap | run-chua-gom 0 | pull-cach 3 ngay  (LUU Y: light_at nay = 25 sau signal-write)
SHARD-PROBE: pending=15 | nguong=15 => IM
crystallized-backfill: hotload 576921B -> tok-high 192307 | headroom 187693 < target 210000 (carry #26)
