[CLAUDE] Scripts: YC-020 5 phan quyet — fold C13/C14/C15 vao TOTAL (nen S185), H24-1 doi don-vi PHIEN (nguong owner 14, 2 flag that fire ngay), grid-c trio liveness, -Detail da cam truoc do

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-08-10 02:59:20 +07:00
parent c2f4523199
commit 2a5290a88e
4 changed files with 75 additions and 25 deletions

View File

@ -729,12 +729,44 @@ else {
foreach ($a in ($anchored | Sort-Object Date -Descending)) {
Write-Host (" anchor {0} {1}:{2}" -f $a.Raw, $a.Rel, $a.Line) -ForegroundColor DarkGray
}
foreach ($a in $anchored) {
if ($a.Date -lt $newest.Date) {
$age = [int]($newest.Date - $a.Date).TotalDays
Write-Flag 'LOW' ("{0}:{1}" -f $a.Rel, $a.Line) `
("title-stale: anchor says {0} but newest governance milestone is {1} ({2}d behind)" -f $a.Raw, $newest.Raw, $age) `
'refresh the title/status anchor date, or state explicitly that the doc is frozen-historical'
# UNIT = SESSIONS not days (YC-020(2) @S185, owner verbatim: 'dong y 14 ngay. (nhung cung
# theo phien luon vi co ngay lam ngay ko)'). A day with 3 ticks ages 3; a dead day ages 0.
# sessions-behind = counter-history ticks strictly AFTER anchor date and <= newest date.
# Threshold = owner key h24_title_freshness_sessions (memory-budget.json).
# Key missing => CHUA DO DUOC (fail-loud, mirror H24-2 - no hardcoded default).
$tfKey = $null
try {
$budJ = Get-Content -Path (Join-Path $RepoRoot '.claude\agent-memory\memory-budget.json') -Raw -Encoding UTF8 | ConvertFrom-Json
$tfKey = $budJ.h24_title_freshness_sessions
} catch {}
$tickDates = @()
try {
$cntJ = Get-Content -Path (Join-Path $RepoRoot '.claude\governance\.session-counter.json') -Raw -Encoding UTF8 | ConvertFrom-Json
foreach ($h in $cntJ.history) {
$dt = [datetime]::MinValue
if ([datetime]::TryParseExact([string]$h.at, 'yyyy-MM-dd', $null, [System.Globalization.DateTimeStyles]::None, [ref]$dt)) { $tickDates += $dt }
}
} catch {}
if ($null -eq $tfKey) {
Write-Host ' CHUA DO DUOC (owner-key): h24_title_freshness_sessions MISSING in memory-budget.json - session-age verdicts WITHHELD (no default; mirror H24-2 fail-loud)' -ForegroundColor Yellow
}
elseif ($tickDates.Count -eq 0) {
Write-Host ' CHUA DO DUOC (tick-source): .session-counter.json history unreadable/empty - cannot count sessions-behind, verdicts WITHHELD' -ForegroundColor Yellow
}
else {
foreach ($a in $anchored) {
if ($a.Date -lt $newest.Date) {
$ageDays = [int]($newest.Date - $a.Date).TotalDays
$ageSess = @($tickDates | Where-Object { $_ -gt $a.Date -and $_ -le $newest.Date }).Count
if ($ageSess -ge [int]$tfKey) {
Write-Flag 'LOW' ("{0}:{1}" -f $a.Rel, $a.Line) `
("title-stale: anchor says {0} but newest governance milestone is {1} ({2} SESSIONS behind [{3}d] >= owner threshold {4})" -f $a.Raw, $newest.Raw, $ageSess, $ageDays, $tfKey) `
'refresh the title/status anchor date, or state explicitly that the doc is frozen-historical'
}
else {
Write-Host (" [ok] {0}:{1} anchor {2} = {3} session(s) behind [{4}d] < threshold {5}" -f $a.Rel, $a.Line, $a.Raw, $ageSess, $ageDays, $tfKey) -ForegroundColor DarkGray
}
}
}
}
}
@ -2054,7 +2086,7 @@ $c12Note = if ($c12Measured) { '' } else { ' -- MEASURED NOTHING (no session log
Write-Host (" C12 raw-engine-bypass flags = {0} [INFORM-only, LOW, NOT folded into TOTAL baseline]{1}" -f $c12Flags, $c12Note) -ForegroundColor DarkGray
# ---------------------------------------------------------------------------
# C13 - carve-out liveness (INFORM-only, NEW @S185; count SEPARATE, NOT in TOTAL)
# C13 - carve-out liveness (NEW @S185; FOLDED vao TOTAL @S185 - YC-020(1) owner 'OK, 1 phien'; nen INFORM = bookend S185)
# ---------------------------------------------------------------------------
# NAMING: this is the script's OWN C-numbering (C1..C12 already exist above). It is a
# DIFFERENT namespace from the S185 run-checklist codes; this detector implements
@ -2103,7 +2135,7 @@ Write-Host (" C12 raw-engine-bypass flags = {0} [INFORM-only, LOW, NOT folded i
# owner-gated decision per the sink contract at the top of this file - never the net
# author's call. The line shape is identical to Write-Flag, so `comm before/after`
# isolates it and a fault-inject greps it exactly like any other flag.
Write-Section 'C13 - carve-out liveness (INFORM-only)'
Write-Section 'C13 - carve-out liveness (TOTAL @S185)'
$c13Flags = 0
$c13Measured = $false
$c13LedgerPath = Join-Path $RepoRoot 'docs\governance\error-ledger.md'
@ -2149,13 +2181,13 @@ else {
# ---- verdicts ----
if (-not $aEmits) {
Write-InformFlag 'scripts/nhip-no-probe.ps1' `
Write-Flag 'LOW' 'scripts/nhip-no-probe.ps1' `
("carve-out grid (a) DEAD - the debt line no longer prints: {0}. error-ledger 'Carve-out o3' requires BOTH grids alive; rank PASS-voi-carve-out is NOT valid while this is dead" -f $aWhy) `
$c13Resolve
$c13Flags++
}
elseif ($callSites.Count -eq 0) {
Write-InformFlag 'scripts/nhip-no-probe.ps1' `
Write-Flag 'LOW' 'scripts/nhip-no-probe.ps1' `
("carve-out grid (a) DEAD-BY-DISCONNECT - the probe emits, but NO stop-point command actually calls it (0 lines matching '-File ...nhip-no-probe.ps1' under .claude/commands). A debt line nobody triggers is not printed 'at every stop point'") `
$c13Resolve
$c13Flags++
@ -2166,7 +2198,7 @@ else {
}
if ($script:H25Scored -le 0) {
Write-InformFlag 'scripts/governance-detectors.ps1 (H25-closeout-ritual)' `
Write-Flag 'LOW' 'scripts/governance-detectors.ps1 (H25-closeout-ritual)' `
'carve-out grid (b) DEAD - the closeout-ritual probe took its [skip] branch and scored 0 close-group this run, i.e. it is wired but measuring NOTHING. error-ledger Carve-out o3 requires BOTH grids alive' `
$c13Resolve
$c13Flags++
@ -2174,12 +2206,27 @@ else {
else {
Write-Host (" [ok] grid (b) ALIVE: H25-closeout-ritual scored {0} close-group(s) this run" -f $script:H25Scored) -ForegroundColor DarkGray
}
# ---- grid (c): trio-memory liveness (YC-020(4) @S185 - owner 'OK' mo C13 sang luoi trio S141) ----
# Absolute-liveness only: FLAG when ZERO harness-*-return.md exists under runs/ (net dead-silent).
# No new threshold invented here (age printed INFORM-style; a threshold = an owner number).
$trioReturns = @(Get-ChildItem -Path (Join-Path $RepoRoot '.claude\workflows\runs') -Recurse -Filter 'harness-*-return.md' -File -ErrorAction SilentlyContinue)
if ($trioReturns.Count -eq 0) {
Write-Flag 'LOW' '.claude/workflows/runs/' `
'carve-out grid (c) DEAD - trio-memory net has ZERO harness-*-return.md on disk across ALL runs: the auto-1-round-per-session loop (S141/S151) is leaving no scribe trace at all' `
$c13Resolve
$c13Flags++
}
else {
$newestTrio = ($trioReturns | Sort-Object LastWriteTime -Descending | Select-Object -First 1)
Write-Host (" [ok] grid (c) ALIVE: {0} harness-*-return.md on disk; newest = {1} ({2:yyyy-MM-dd HH:mm})" -f $trioReturns.Count, (Rel $newestTrio.FullName), $newestTrio.LastWriteTime) -ForegroundColor DarkGray
}
}
$c13Note = if ($c13Measured) { '' } else { ' -- MEASURED NOTHING (skipped above); a 0 after a skip is not a green' }
Write-Host (" C13 carve-out-liveness flags = {0} [INFORM-only, LOW, NOT folded into TOTAL baseline]{1}" -f $c13Flags, $c13Note) -ForegroundColor DarkGray
Write-Host (" C13 carve-out-liveness flags = {0} [FOLDED vao TOTAL @S185 YC-020(1) - nen INFORM = bookend S185]{1}" -f $c13Flags, $c13Note) -ForegroundColor DarkGray
# ---------------------------------------------------------------------------
# C14 - stamp_verify mirror-drift (INFORM-only, NEW @S185; count SEPARATE, NOT in TOTAL)
# C14 - stamp_verify mirror-drift (NEW @S185; FOLDED vao TOTAL @S185 - YC-020(1))
# ---------------------------------------------------------------------------
# NAMING: script-local C-numbering (see C13 note). This implements S185 checklist C-19.
#
@ -2205,7 +2252,7 @@ Write-Host (" C13 carve-out-liveness flags = {0} [INFORM-only, LOW, NOT folded
# with a machine-specific prefix silently degrades to the else-branch on any other
# machine, and a silent degrade reads exactly like "clean" - the S122 W5 lesson already
# paid for once in this file. Hub unreachable => "CHUA DO DUOC", never [ok], never silence.
Write-Section 'C14 - stamp_verify mirror-drift (INFORM-only)'
Write-Section 'C14 - stamp_verify mirror-drift (TOTAL @S185)'
$c14Flags = 0
$c14Measured = $false
@ -2228,7 +2275,7 @@ if ($null -ne $p1) { $p2 = Split-Path $p1 -Parent; if ($null -ne $p2) { $hubRoot
$mirHub = if ($null -eq $hubRoot) { $null } else { Join-Path $hubRoot 'scripts\stamp_verify.py' }
if (-not (Test-Path $mirLocal)) {
Write-InformFlag 'scripts/stamp_verify.py' `
Write-Flag 'LOW' 'scripts/stamp_verify.py' `
'stamp mirror MISSING locally - the ported verifier is gone, so /check-email and /send-email fall back to the regex-pin path with nothing checking the canon' `
're-pull scripts/stamp_verify.py from AI_INFRA, or declare the regex-pin path canonical and retire the mirror in the SAME change'
$c14Flags++; $c14Measured = $true
@ -2242,7 +2289,7 @@ else {
$hl = Get-MirrorHashes $mirLocal
$hh = Get-MirrorHashes $mirHub
if ($hl.Logic -ne $hh.Logic) {
Write-InformFlag 'scripts/stamp_verify.py' `
Write-Flag 'LOW' 'scripts/stamp_verify.py' `
("stamp mirror DRIFT: local logic-sha {0} != hub logic-sha {1} (local {2} lines / hub {3} lines; raw-sha local {4} hub {5}) - the mirror no longer carries the hub canon, so a stamp verified here can pass while the hub would fail it" -f `
$hl.Logic.Substring(0, 12), $hh.Logic.Substring(0, 12), $hl.Lines, $hh.Lines, $hl.Raw.Substring(0, 8), $hh.Raw.Substring(0, 8)) `
'BLOCKING NOTHING (INFORM): re-pull the hub copy over scripts/stamp_verify.py keeping ONLY the mirror-of header note, then re-run this detector'
@ -2254,10 +2301,10 @@ else {
}
}
$c14Note = if ($c14Measured) { '' } else { ' -- MEASURED NOTHING (hub unreachable); a 0 here is "chua do duoc", not a green' }
Write-Host (" C14 stamp-mirror-drift flags = {0} [INFORM-only, LOW, NOT folded into TOTAL baseline]{1}" -f $c14Flags, $c14Note) -ForegroundColor DarkGray
Write-Host (" C14 stamp-mirror-drift flags = {0} [FOLDED vao TOTAL @S185 YC-020(1)]{1}" -f $c14Flags, $c14Note) -ForegroundColor DarkGray
# ---------------------------------------------------------------------------
# C15 - V-5 encoding predicate (INFORM-only, NEW @S185; count SEPARATE, NOT in TOTAL)
# C15 - V-5 encoding predicate (NEW @S185; FOLDED vao TOTAL @S185 - YC-020(1); rank-1 data-loss = MED)
# ---------------------------------------------------------------------------
# NAMING: script-local C-numbering (see C13 note). This implements S185 checklist C-11.
#
@ -2292,7 +2339,7 @@ Write-Host (" C14 stamp-mirror-drift flags = {0} [INFORM-only, LOW, NOT folded
# The mojibake markers are built from CODE POINTS (same U helper as the VN tokens) so this
# .ps1 stays pure-ASCII on disk (gotcha #30) and so the detector never carries a literal
# specimen of the thing it hunts.
Write-Section 'C15 - V-5 encoding predicate (INFORM-only)'
Write-Section 'C15 - V-5 encoding predicate (TOTAL @S185)'
$c15Flags = 0
$c15Measured = $false
@ -2352,14 +2399,14 @@ else {
$v5Files.Count, $lossFiles.Count, $lossHits, $mojiFiles.Count, $mojiHits)
if ($lossFiles.Count -gt 0) {
Write-InformFlag 'V-5 rank-1' `
Write-Flag 'MED' 'V-5 rank-1' `
("encoding DATA LOSS: {0} file(s) / {1} raw U+FFFD - the original bytes are gone and no re-decode recovers them; only the source artifact can" -f $lossFiles.Count, $lossHits) `
're-fetch each file from its source artifact (a re-save will NOT restore the lost characters); if a file is a frozen record, note the loss in it explicitly so it is not read as content'
$c15Flags++
foreach ($lf in $lossFiles) { Write-Host (" [rank-1] {0}" -f $lf) -ForegroundColor DarkGray }
}
if ($mojiFiles.Count -gt 0) {
Write-InformFlag 'V-5 rank-2' `
Write-Flag 'LOW' 'V-5 rank-2' `
("encoding MOJIBAKE-ONLY: {0} file(s) / {1} double-encoding signature(s) - nothing is lost, a correct re-decode repairs it" -f $mojiFiles.Count, $mojiHits) `
're-decode the file as UTF-8 and re-save; verify by re-running this detector (rank-2 must go to 0 without rank-1 rising)'
$c15Flags++
@ -2370,7 +2417,7 @@ else {
}
}
$c15Note = if ($c15Measured) { '' } else { ' -- MEASURED NOTHING (skipped above); a 0 after a skip is not a green' }
Write-Host (" C15 V-5 encoding flags = {0} [INFORM-only, LOW, NOT folded into TOTAL baseline]{1}" -f $c15Flags, $c15Note) -ForegroundColor DarkGray
Write-Host (" C15 V-5 encoding flags = {0} [FOLDED vao TOTAL @S185 YC-020(1); rank-1 = MED]{1}" -f $c15Flags, $c15Note) -ForegroundColor DarkGray
# ---------------------------------------------------------------------------
# Summary + C4 self-exclusion audit (RUNTIME proof)
@ -2395,7 +2442,7 @@ if ($selfInScan -eq 0 -and $leaked -eq 0) {
Write-Host ''
Write-Host ("TOTAL FLAGS: {0}" -f $script:FlagCount) -ForegroundColor Cyan
Write-Host ("INFORM-ONLY (new nets C6 cite-2-tier + H24-4 pending-flip + H24-5 counter-ancestor-classify + C9 hmw-width-drift + C11 h24-flag-form + C12 raw-engine-bypass + C13 carve-out-liveness + C14 stamp-mirror-drift + C15 V-5-encoding + the L7-bolt 'chua do duoc' lines): {0} - counted SEPARATELY, NOT in TOTAL above (anti-Goodhart, owner-set; fold+sev-raise is post-triage)" -f $script:InformCount) -ForegroundColor DarkGray
Write-Host ("INFORM-ONLY (new nets C6 cite-2-tier + H24-4 pending-flip + H24-5 counter-ancestor-classify + C9 hmw-width-drift + C11 h24-flag-form + C12 raw-engine-bypass + the L7-bolt 'chua do duoc' lines): {0} - counted SEPARATELY, NOT in TOTAL above (anti-Goodhart, owner-set; fold+sev-raise is post-triage)" -f $script:InformCount) -ForegroundColor DarkGray
Write-Host 'NOTE: DETECT-only lowering net. Exit 0 always (never fails build). FLAGs are advisory.' -ForegroundColor DarkGray
exit 0