wal: pause

This commit is contained in:
pqhuy1987
2026-07-29 14:53:58 +07:00
parent ea962b1e59
commit febe6b1696
19 changed files with 645 additions and 43 deletions

View File

@ -1086,17 +1086,25 @@ if ($roster.Count -eq 0) {
Write-Host ' [skip] no .claude/agents/*.md roster - nothing to check' -ForegroundColor DarkGray
}
else {
# Evidence-of-run: scan runs/*/sub-*.md and map each filename prefix to a roster role.
# Two-step greedy parse: 'sub-<role>-<numeric-idx>.md' first, else 'sub-<rest>.md'.
# Evidence-of-run: scan runs/*/ for per-role artifacts and map filename prefix to a roster role.
# Three-step greedy parse: 'sub-<role>-<numeric-idx>.md', else 'sub-<rest>.md', else '<role>-return.md'.
# @S159 FIX (ctx-audit FLAG-6): the filter used to be the literal glob 'sub-*.md', so the trio
# returns (harness-eval-return.md / harness-refine-return.md / harness-audit-return.md) were
# INVISIBLE to this detector. Measured on the S159 bookend: 9 spawns ran, the glob saw 6 -
# it dropped exactly the 3 most expensive lanes. A grid that cannot see the priciest lanes
# reports 'clean' for the very roles most likely to be missing. Same class as the standing
# carry 'C11(b) filter'; that carry now has a real case behind it, not a hypothesis.
$runsDir = Join-Path $RepoRoot '.claude\workflows\runs'
$ran = @{} # role -> ran (exact roster match)
$unmapped = @{} # prefix -> seen (not an exact roster role)
if (Test-Path $runsDir) {
$subs = Get-ChildItem -Path $runsDir -Recurse -Filter 'sub-*.md' -File -ErrorAction SilentlyContinue
$subs = @(Get-ChildItem -Path $runsDir -Recurse -File -ErrorAction SilentlyContinue |
Where-Object { $_.Name -match '^(sub-.+|.+-return)\.md$' })
foreach ($s in $subs) {
$cand = $null
if ($s.Name -match '^sub-(.+)-\d+\.md$') { $cand = $Matches[1] }
elseif ($s.Name -match '^sub-(.+)\.md$') { $cand = $Matches[1] }
elseif ($s.Name -match '^(.+)-return\.md$') { $cand = $Matches[1] }
if ($null -eq $cand) { continue }
if ($rosterSet.ContainsKey($cand)) { $ran[$cand] = $true } else { $unmapped[$cand] = $true }
}
@ -1604,7 +1612,7 @@ Write-Host (" C9 width-drift flags = {0} [INFORM-only, LOW, NOT folded into TOT
# _context-s-<N>.md, and (c) the HIGHEST N must be OPEN (no _end / closed.md) - because a
# running session must have an open logic-session to write into. All-closed => nobody opened
# one for the session that is running right now.
# 🔸 KHAI THAT - what this CANNOT do: it cannot prove the folder was opened EARLY (on time).
# [!] KHAI THAT - what this CANNOT do: it cannot prove the folder was opened EARLY (on time).
# A late-but-present folder reads identical to a punctual one. It catches ABSENCE, not
# LATENESS. Closing that gap needs a timestamp compare against session start, which the
# detector has no reliable source for. Do not read a green C10 as "ritual ran on time".
@ -1757,7 +1765,10 @@ else {
Where-Object { $_.LastWriteTime -ge $C11_LAND_DATE })
foreach ($rf in $freshFolders) {
$subMd = @(Get-ChildItem -LiteralPath $rf.FullName -Filter 'sub-*.md' -File -ErrorAction SilentlyContinue)
# @S159: mirror of the C11(b) filter fix above - '<role>-return.md' counts as a per-role
# artifact too, otherwise the trio lanes are invisible here as well (ctx-audit FLAG-6).
$subMd = @(Get-ChildItem -LiteralPath $rf.FullName -File -ErrorAction SilentlyContinue |
Where-Object { $_.Name -match '^(sub-.+|.+-return)\.md$' })
foreach ($sm in $subMd) {
# ---- (a) FLAG-khuon: H24 auditor sub-file must class-tag every raised flag ----

View File

@ -630,10 +630,16 @@ def mind_check(session_n, root=None, draft=None, force_closed=False):
p, hub, legacy = _count_pause_on_disk(session_dir)
n = len(blocks)
ok = n in (p, p + 1)
# @S159 NOI: block-0 + p refresh/pause + toi da 2 refresh BOOKEND (@open, @close).
# Truoc S159 chi cho {p, p+1} => refresh-ngoai-pause la trang-thai THIET-KE KHONG CHO PHEP,
# trong khi ctx-audit @S159 lai DE-XUAT dung no de vá 4 FLAG (muc E phu 0/9 luot).
# Bat-bien cu KHONG SAI - no ma-hoa dung gia-dinh "block-0 ghi CUOI nghi-thuc mo".
# Nay nghi-thuc cho refresh @bookend => tran phai noi theo, KEM check thu-tu (10) duoi.
ok = p <= n <= p + 3
detail = ['|block| = %d ; p (DEM DIA) = %d [_pause-*.md=%d + pause-*.md=%d dual-accept]'
% (n, p, hub, legacy),
'ky vong |block| thuoc {%d, %d} (block-0 + 1 refresh/pause)' % (p, p + 1)]
'ky vong %d <= |block| <= %d (block-0 + %d refresh/pause + toi da 2 refresh bookend)'
% (p, p + 3, p)]
decl = _self_declared(session_dir)
info = []
if decl is None:
@ -661,13 +667,65 @@ def mind_check(session_n, root=None, draft=None, force_closed=False):
_check_context_cap(checks, session_dir, session_n, caps['session_ctx_kb'])
_check_structure(checks, blocks, canonical.name)
_check_bookend_order(checks, canonical, repo_root)
return _render(out, checks, 'full/%s' % mode)
def _check_bookend_order(checks, canonical, repo_root):
"""(10) THU-TU bookend: `_mind` phai duoc ghi/refresh SAU khi cac vong kiem da bao xong.
Vi sao ton tai (@S159): `session-start.md` Phase 3.5 bat ghi block-0 o CUOI nghi-thuc mo
("noi-dung giau nhat chi ton tai SAU khi cac vong kiem da bao xong"). Luat DUNG, co that,
va van bi vi-pham - lead @S159 ghi block-0 luc 08:32:27 trong khi vong do dau 08:46:03 /
cuoi 09:26:54 => chup som 13m36s. Hau-qua do duoc: muc E phu 0/9 luot spawn, 4/5 nhan muc D
lech. MAY KHONG BAT DUOC - `ctx-audit` phai doi-chieu mtime BANG TAY moi ra.
=> Bai: chan duoc = LUAT SOI-DUOC, khong phai tri-nho. Day la lop soi do.
Nac trung-thuc: INFORM (CO), KHONG gate. mtime la proxy (git checkout / copy lam sai lech),
va ban cai nay chua qua fault-inject 2-chieu. Nang len TRUOT khi da co ca do that.
"""
runs = Path(repo_root) / '.claude' / 'workflows' / 'runs'
if not runs.is_dir():
_chk(checks, '10', 'thu-tu bookend vs _mind', SKIP,
['khong co thu-muc runs/ => bo qua co khai'])
return
newest, newest_dir = 0.0, None
for d in runs.iterdir():
if not d.is_dir() or 'bookend' not in d.name:
continue
for f in d.glob('*.md'):
try:
m = f.stat().st_mtime
except OSError:
continue
if m > newest:
newest, newest_dir = m, d.name
if newest_dir is None:
_chk(checks, '10', 'thu-tu bookend vs _mind', SKIP,
['0 run-folder ten chua "bookend" => bo qua co khai (khong suy ra "dat")'])
return
try:
mind_m = canonical.stat().st_mtime
except OSError:
_chk(checks, '10', 'thu-tu bookend vs _mind', SKIP, ['khong doc duoc mtime _mind'])
return
_fmt = lambda t: datetime.datetime.fromtimestamp(t).strftime('%Y-%m-%dT%H:%M:%S')
lag = newest - mind_m
det = ['_mind mtime = %s' % _fmt(mind_m),
'artifact bookend moi nhat = %s (%s)' % (_fmt(newest), newest_dir)]
if lag > 0:
det.append('=> _mind CU HON artifact %d giay (%.1f phut) - block top co the CHUA phu '
'cac vong kiem chay sau no (muc E / nhan muc D de lech)' % (int(lag), lag / 60.0))
det.append('vá: chen 1 block refresh SAU khi vong cuoi bao xong (tran (6) da noi cho ca nay)')
else:
det.append('=> _mind moi hon hoac bang artifact cuoi: thu-tu DUNG')
_chk(checks, '10', 'thu-tu bookend vs _mind', CO if lag > 0 else DAT, det)
def _render(out, checks, mode_note):
"""Deterministic 4-level report. rc = 1 iff >=1 TRUOT (co / bo-qua-co-khai never gate)."""
order = {'0': 0, '0b': 1, '1': 2, '2': 3, '3': 4, '4': 5, '5': 6, '6': 7, '7': 8,
'8': 9, '9': 10}
'8': 9, '9': 10, '10': 11}
checks = sorted(checks, key=lambda c: order.get(c['id'], 99))
tally = {DAT: 0, TRUOT: 0, CO: 0, SKIP: 0}
for c in checks: