Files
ft/CodexOutput/upserver/KVSaveRouteTests/prepare_delivery.py

103 lines
9.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Main-session documentation checkpoint and immutable review package creation."""
from pathlib import Path
import hashlib, json, re
from datetime import datetime, timezone
HERE=Path(__file__).resolve().parent
UP=HERE.parent
ROOT=HERE.parents[2]
def read(p): return json.loads(p.read_text(encoding='utf-8-sig'))
def write(p,v): p.write_text(json.dumps(v,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
def sha(p): return hashlib.sha256(p.read_bytes()).hexdigest().upper()
checkpoint='''
## 2026-09-24 4B3A检查点4:限定自审、范围与交付封板(主会话部分)
自审补齐示例迟到回调共享内存不变与Read/Close竞争断言,新入口默认/Android/非Editor三条件最终各13组544断言、退出0;原检查点3的508断言日志保留。生产实现未随补测变动,故已通过的Unity与旧全量回归不重复执行。
2101项原源码仅PlayFabMgr变化;剥离新增块后原PF字节完全一致;39项设计材料与221项原B2交付也仅PF变化。新增Scripts仅键结果与Editor host,另加Editor转接及三个meta;业务调用、旧测试/工程、底层协议和场景资源未改。范围审计保留机器证据。
已形成交付矩阵、限定自审、独立实施复核提示词、冻结实施记录与交付SHA256清单;入口/状态/TODO/机器todoItem同步为“4B3A实现与自验完成,待独立实施复核”。B3A-19外部实施复核及主会话关闭裁决尚未完成,A/B3/G4未关闭,B/C不获编码批准。KVSync首败及3C L7历史问题保持开放;P2-α正式启用门保持。外部接受并经主会话核hash/逐条裁决后,若无需复审则自动进入B完整方案准备。
'''
for name in ['阶段4B3A实施记录-2026-09-24.md','开发日志.md']:
path=UP/name
assert '2026-09-24 4B3A检查点4:' not in path.read_text(encoding='utf-8-sig')
with path.open('a',encoding='utf-8') as f: f.write(checkpoint)
current='''## 当前有效状态:4B3A实现与自验完成,待独立实施复核(2026-09-24)
4B3分期与A方案独立审查双PASS,主会话已核对39项材料+2101项源码hash,逐条裁决九项合同和四条P3并[批准限定A实施](阶段4B3分期与4B3A方案审查裁决与实施批准-2026-09-24.md)。检查点0~3及检查点4主会话交付部分已完成,见[交付矩阵](阶段4B3A交付与验收矩阵-2026-09-24.md)、[限定自审](阶段4B3A限定代码自审-2026-09-24.md)与[实施记录](阶段4B3A实施记录-2026-09-24.md)。
改动内容:PlayFabMgr新增固定句柄Read/Write/Flush/Wait四入口,新增键读取三态结果及两个Editor验证文件。2101项原源码仅PlayFabMgr变化,去掉新增块后旧PF字节完全一致;31业务模块、User/Agg/Context/Owner/Guard、旧工程和场景未改。其余新增文件是测试、验证日志与审查文档;没有接通普通玩法保存。
验证:新入口三个条件各13组544断言;Unity新入口34断言、B2-20真实31对象双epoch83断言,均恢复成功,编译0错误0警告;4B2离线75组1713断言、关闭故障21断言、服务双条件各8组73断言,4A/4B1及旧核心回归最终通过。**KVSync首轮85/86、重跑86/86,根因未定;旧3C L7历史问题仍开放。** NetworkTransport沿用旧依赖targets仅构建通过,未运行正式代理。
### 当前todoItem与责任
- [x] B3-Review:设计受审hash核对、逐条裁决及A实施批准。
- [x] B3A-C0~C3:四入口/键结果/限定Editor宿主、故障竞争测试、Unity及全量回归。
- [x] B3A-C4作者部分:范围/hash、限定自审、交付矩阵、送审提示词、每检查点日志。
- [ ] **B3A-19:外部独立实施复核→主会话核hash/逐条裁决→必要修复→A正式关闭。** 当前待办在外部评审侧,按[实施复核提示词](其他AI审查提示词-4B3A实施-2026-09-24.md)落盘报告;审核者不修改共享状态。
- [ ] B3B/B3C各自完整方案及独立评审,未批准编码。A关闭且无需复审后自动进入B完整方案准备,不再询问是否继续。
- [ ] KVSync StorageError、3C L7根因定位;P2-α真实档专项独立审查与用户产品确认;4C、身份、tickets有界历史、4D/G4启用门。
**4B1/4B2已关闭;4B3A已实现但未关闭,整个4B3/4B/G4未通过。** 正式地址固定http://s101.local:18080/;本轮正式请求0,Unity仅CLI Loop,不用UnitySkills,无PlayMode、打包或Git提交。封板见[交付hash](KVSaveRouteTests/checkpoint4-delivery-hashes.json),机器状态见[当前todoItem](阶段4B3当前TodoItem-2026-09-24.json)。
### 以下为历史快照(当前以本节为准)
'''
for name,title in [('接手入口.md','# 接手入口:s101客户端迁移'),('开发状态.md','# 开发状态:4B3A待独立实施复核'),('TODO.md','# TODO:4B3A实施复核与关闭')]:
path=UP/name
old=path.read_text(encoding='utf-8-sig')
path.write_text(title+'\n\n'+current+old.split('\n',1)[1].lstrip(),encoding='utf-8')
todo=read(UP/'阶段4B3当前TodoItem-2026-09-24.json')
todo.update(phase='4B3A-implementation-awaiting-review',implementationApproved=True,phase4B3AClosed=False,
nextResponsibleSide='independent-reviewer',implementationScope='4B3A only; 4B3B/C not approved')
for item in todo['todoItem']:
if item['id']=='B3-Review': item.update(status='completed',detail='39+2101项开工hash通过;独立双PASS及四P3已裁决')
if item['id']=='B3A-Implementation': item.update(status='implemented-awaiting-independent-review',detail='四入口/键三态/Editor验证;三条件各13组544断言,Unity34及旧B2-20 83;未关闭')
if item['id']=='KVSync-StorageError': item['detail']='本轮85/86→86/86;首败保留、根因未定'
for identifier,detail in [('B3A-C0','设计裁决与批准'),('B3A-C1','ReadKV与三态键结果'),('B3A-C2','Write/Flush/Wait直接透传与故障竞争测试'),('B3A-C3','条件宿主/Unity/旧全量回归;保留首败'),('B3A-C4-author','范围/hash/自审/交付/提示词封板')]:
todo['todoItem'].append(dict(id=identifier,status='completed',detail=detail))
todo['todoItem'].append(dict(id='B3A-19',status='awaiting-independent-implementation-review',detail='外部复核后主会话核受审hash逐条裁决,才可关闭A并自动进入B完整设计'))
write(UP/'阶段4B3当前TodoItem-2026-09-24.json',todo)
write(HERE/'checkpoint4-todo-snapshot.json',todo)
(HERE/'checkpoint4-implementation-record.md').write_bytes((UP/'阶段4B3A实施记录-2026-09-24.md').read_bytes())
def unity(name):
o=read(HERE/name)
assert o['Success'] is True
v=json.loads(o['Result'])
assert v['success'] is True and v['restored'] is True
return v
finalRuns={}
for variant in ['default','android','player']:
content=(HERE/f'checkpoint4-route-{variant}.log').read_text(encoding='utf-8-sig')
m=re.search(r'RESULT groups=(\d+) assertions=(\d+) failed=(\d+) run=(.+)',content)
assert m and m.group(1,2,3)==('13','544','0')
finalRuns[variant]=dict(groups=13,assertions=544,failed=0,resultPath=(Path(m[4].strip())/'result.json').relative_to(ROOT).as_posix())
assert all(r['exitCode']==0 for r in read(HERE/'checkpoint4-route-exits.json'))
assert read(HERE/'checkpoint3-unity-compile-permitted.log')['ErrorCount']==0
write(HERE/'checkpoint4-validation-summary.json',dict(route=finalRuns,unityRoute=unity('checkpoint3-unity-route.log'),unityB220=unity('checkpoint3-unity-b220.log'),networkBuildWithExistingDependenciesExitCode=0,formalRequests=0,knownIssues=['KVSync 85/86 then 86/86; cause unresolved','Historical Stage3C L7 unresolved; this run 8/8'],playerLinkOrBuildValidated=False))
paths=set()
for base in [UP/'阶段4B3方案受审基线-2026-09-24.json',UP/'KVGameLoadTests/checkpoint4-delivery-hashes.json']:
paths.add(base)
paths.update(ROOT/f['path'] for f in read(base)['files'])
for name in ['阶段4B3分期与4B3A方案独立审查-2026-09-24.md','阶段4B3分期与4B3A方案审查裁决与实施批准-2026-09-24.md','阶段4B3A交付与验收矩阵-2026-09-24.md','阶段4B3A限定代码自审-2026-09-24.md','其他AI审查提示词-4B3A实施-2026-09-24.md','B3DesignAudit/review-ruling-hashes-2026-09-24.json']:
paths.add(UP/name)
for relative in ['Client/Assets/Scripts/Core/PlayFabMgr.cs','Client/Assets/Scripts/Services/PlayerData/PlayerKVKeyReadResult.cs','Client/Assets/Scripts/Services/PlayerData/PlayerKVSaveRouteEditorValidationHost.cs','Client/Assets/Editor/KVSaveRouteValidation.cs']:
paths.add(ROOT/relative)
if not relative.endswith('PlayFabMgr.cs'): paths.add(ROOT/(relative+'.meta'))
paths.update(p for p in HERE.iterdir() if p.is_file() and p.name!='checkpoint4-delivery-hashes.json')
paths.update(HERE.glob('runs/*/result.json'))
assert all(p.is_file() for p in paths)
manifest=dict(schemaVersion=1,phase='4B3A-implementation',status='awaiting-independent-implementation-review',
createdAt=datetime.now(timezone.utc).isoformat(),stageClosed=False,formalRequests=0,gitCommitCreated=False,
note='Includes dependencies at delivery state, frozen records, original failures and final evidence. Mutable entry/status/TODO/live logs excluded; frozen implementation/todo included. Do not overwrite this manifest during review.',
files=[dict(path=p.relative_to(ROOT).as_posix(),sha256=sha(p)) for p in sorted(paths)])
manifest['fileCount']=len(manifest['files'])
write(HERE/'checkpoint4-delivery-hashes.json',manifest)
print(json.dumps(dict(fileCount=manifest['fileCount'],manifestSha256=sha(HERE/'checkpoint4-delivery-hashes.json'),finalRuns=finalRuns),ensure_ascii=False,indent=2))