Files
solution-erp/scripts/measure-agent-memory.ps1
pqhuy1987 628132cf10
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 6m24s
[CLAUDE] Scripts: S167 governance — split _INDEX auto-rotate + 3 script _INDEX*-glob + tran _mind 48KB + ratified-stamps
Slot(57) anh "auto": cicd-monitor _INDEX 21.468->8.756B (42,7% cap) + _INDEX-2026-H1.md tang-lanh;
3 script cung-class nhan _INDEX*.md (gate chong-haystack-duong-gia + doc MOI index-file; measure truc
l2_index; shard-probe loai-tru); fault-inject 2-chieu PASS + A7 427/427 lan dau sach (va needle-quote
test-specialist + mega-line + 29-entry lac-section). Slot(58) anh "nang tran": mind_ctx_kb 32->48
(live-verified 62,2%). G-1 RATIFIED stamps KhkkWorkflowPanel x2 app (SHA-pair giu) + STATUS 622/counter-41.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-01 13:06:39 +07:00

42 lines
1.6 KiB
PowerShell

# measure-agent-memory.ps1 - Harness-9 seed-by-measure (2026-06-17)
# Measures REAL bytes of each agent-memory tier so memory-budget.json caps are
# set from measurement, NOT an imagined "headroom" number (Harness-9 step a).
# Output: JSON to stdout. ASCII-only (gotcha #30). PS 5.1 compatible.
param([string]$Root = "$PSScriptRoot\..\.claude\agent-memory")
if (-not (Test-Path $Root)) { Write-Error "agent-memory root not found: $Root"; exit 1 }
$rows = @()
Get-ChildItem -Path $Root -Directory | Sort-Object Name | ForEach-Object {
$dir = $_.FullName
$name = $_.Name
$mem = Join-Path $dir 'MEMORY.md'
$l1 = if (Test-Path $mem) { (Get-Item $mem).Length } else { 0 }
$archDir = Join-Path $dir 'archive'
$verbatim = 0; $index = 0; $gist = 0
if (Test-Path $archDir) {
Get-ChildItem -Path $archDir -Filter *.md | ForEach-Object {
if ($_.Name -like '_INDEX*.md') { $index += $_.Length } # S167 split: rotated _INDEX-<period>.md stays in the l2_index axis (not verbatim)
elseif ($_.Name -like '*.gist.md') { $gist += $_.Length }
else { $verbatim += $_.Length }
}
}
$rows += [ordered]@{
agent = $name
l1_hot_bytes = $l1
l2_verbatim_bytes = $verbatim
l2_index_bytes = $index
l2_gist_bytes = $gist
l1_over_30kb = ($l1 -gt 30720)
}
}
[ordered]@{
measured_at_note = "run date stamped by caller (Date.now unavailable in workflow scripts)"
soft_cap_l1_bytes = 30720
autoinject_cap_bytes = 25600
agents = $rows
} | ConvertTo-Json -Depth 5