wal: pause
This commit is contained in:
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user