Files
CyberGril/docs/requirements/handoff-HEL-894.json
T
zonggongandmultica-agent 152479b350 HEL-894 rework: a cancelled close owns nothing it did not start — aclose cancellation is now a two-phase ownership protocol - the manager's independent pinned-SDK review of ceb0f35 reproduced two combo holes in the HEL-889 close path: (1) cancelling aclose AFTER backend.aclose began made the shielded finish keep running unowned in the background while the outer except already released the lock and cleared closing — the layer was reported reusable (closing=false/closed=false/client usable), a new tick claimed a batch onto real HTTP, then the orphaned finish closed Qdrant under it (SDK-only branch: batch failed on 'QdrantLocal instance is closed' with row_done=0/llm_used=1; with the caller closing the store afterwards the late worker died on ProgrammingError 'Cannot operate on a closed database' and the reopened batch sat pending), and (2) cancelling a SECOND aclose that was still WAITING for the close lock ran the same except and cleared the FIRST closer's flag (first close still pending but signal=false, a new batch ran to done while the original worker was still on the wire). SemanticMemory.aclose now states the revocation boundary explicitly: the DRAIN phase (nothing closed yet) stays revocable — a cancelled caller leaves everything open, resets the closing signal and the layer remains usable (HEL-889 semantics preserved); the FINISH phase (backend.aclose begun) is irreversible — a cancelled caller keeps the closing markers (a half-closed layer is never reported usable, ticks keep refusing), keeps the lock, and waits — repeated cancels only re-shield — for the layer-owned close task it started (self._close_task, created exactly once with asyncio.create_task and stored on the layer, never dropped to the background) to land before propagating CancelledError, so resources close exactly once; _finish_close also joins this layer's OWN executor via asyncio.to_thread so a cancelled caller can never block the event loop on a synchronous shutdown wait (caller-injected executors stay caller-owned), and signal reset is ownership-gated by owns_close: only the call that actually acquired the lock and set the signal may clear it, and only while no close task exists — a lock waiter cancelled on acquisition touches nothing; module docstring, aclose docstring and the app lifespan comment state the same contract; verification: 299 python tests pass on 3.11.16 venv + requirements.lock offline (5 new tests/test_rework_hel894.py cases, all barrier-driven real product paths: finish-phase cancel keeps ownership and refuses new work with zero sends and zero budget / repeated cancels during finish land the close exactly once / a same-phase second aclose waits then returns idempotently while a third cancelled lock-waiter touches nothing / waiter-cancel + owner draining + refused new tick + original worker completing combo / drain-phase cancel still re-arms for reuse), ruff clean (src/tests/tools), no frontend changes (frontend checks not re-run, stated honestly); pinned mem0 2.2.1 on the deterministic boundary (512-dim stand-in before TextEmbedding construction, loopback-only): new tools/verify_close_ownership_hel894.py 16/16 reruns the manager's two negatives in the same shape with assertions restated for the new protocol (F1 SDK-only: after the cancel closing=true/closed=false/client usable and the cancelled caller does not return before its close lands; the new tick is refused with zero gateway arrivals, batch queued/owner NULL/attempts 0 and llm_used=0; after the gate the close lands exactly once with live_workers=0 and the reopened batch is intact queued/row_done=0/llm_used=0 — before the fix the same run gave closing=false, a claimed batch, QdrantLocal instance is closed, failed/pending with row_done=0/llm_used=1; F2 + store-close branch: same shape and no late error — before: ProgrammingError; W waiter cancel: closing stays set, the new batch stays queued, the original worker completes done/row_done=1 after release and the owner's close then lands once); the manager's review_hel889_cancel.py re-run VERBATIM on the pristine ceb0f35 first reproduced both defects exactly (docs/rework/hel894/before-ceb0f35.json matches the manager's independent JSON), and on the fixed tree stops honestly at its own premise assert server.arrived — 'a finish-phase-cancelled layer still starts new real HTTP' is structurally gone because tick refuses while closing is held (verbatim-after-fix.log; original negative and baseline kept); regressions all green: verify_shutdown_queued_hel889.py 12/12 (queued cancel, timeout drain, between-rows resume, drain-cancel re-arm, concurrent close all preserved), verify_inflight_lifecycle_hel886.py 6/6, verify_semantic_recovery_hel885.py 7/7, verify_mem0_real_hel874.py 12/12, check_release_offline_hel882.py R1-R7 15/15, both manager review_hel882_{partial,extra}.py scripts re-run verbatim pass (extra's uv rc=2 is its own expected negative), HEL-889 same-shape rerun review_hel886_edges_rerun_hel889.py passes; crash semantics unchanged and still honest (unknown wire outcomes billed, proof-gated retries, strict-once not claimed); runbook §4 gains the HEL-894 cancellation-ownership paragraph, docs/requirements/handoff-HEL-894.json written, dual-target requirement checks 4/4 (origin/main and origin/agent/agent/de8874a3803b, with and without handoff); zero real LLM, zero real embeddings, zero non-loopback outbound, authoritative ledgers and freezes untouched, not deployed, PR not merged, no visual changes
Co-authored-by: multica-agent <github@multica.ai>
2026-10-27 01:43:54 +08:00

53 lines
9.2 KiB
JSON
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.
{
"baseline_version": "1.11",
"read_commit": "ceb0f35418f0d0b28b4e2a359615194db8eb4567",
"task": "HEL-894 返工(总管对 HEL-889 head ceb0f35 独立复审确认的关闭取消两处组合漏洞一次修完):关闭提交阶段被取消仍须保持关闭所有权——semantic.py 原实现 shield(_finish()) 让内部关闭在后台继续,却向外抛取消、释放锁并清 closing,层次被误报可续用,新 tick 把批次领进即将消失的资源(总管实际固定 SDK 屏障复现:取消返回 closing=false/closed=false/client 可用 → 新批 HTTP 已接受未答 → 旧 _finish 关 Qdrant → 不关 Store 也 failed/row_done=0/llm_used=1(QdrantLocal instance is closed);调用方随后关 Store 则晚到 ProgrammingError,重开 pending/row_done=0);取消等锁者不得修改持锁关闭者状态——第二 aclose 等锁即取消,外层 except 清掉第一关闭者的 closing(固定 SDK 复现第一 close 仍 pending 但 signal=false,原 worker 未放行时新批已 done)。零真实调用、零真实嵌入、零下载、不部署、不合并、不改视觉、不碰权威三账、不变真实 cap 与冻结余额、不改运行时/模型/认证",
"requirement_ids": [
"CG-006",
"CG-008",
"CG-011",
"CG-013",
"CG-014",
"CG-015",
"CG-016",
"CG-018",
"CG-021",
"AM-001",
"AM-002",
"AM-003",
"UX-004",
"UX-006",
"GOV-001",
"GOV-002",
"GOV-003",
"GOV-004",
"GOV-005",
"GOV-006",
"DEL-001"
],
"deliverable": "在统一候选母线 hel-870-assembly(基于 ceb0f35 正常追加,PR#11 只追加不强推不合并)完成两项修正:1) 两阶段取消语义——aclose 明确排空可撤销阶段(尚未关任何资源:取消什么都不关、closing 复位、层次可续用,保持 HEL-889 行为)与提交不可逆阶段(backend.aclose 已开始:被取消的调用方不清 closing、不放行 tick(半关闭绝不宣称可用)、不释放锁,等待自己启动的层持有关闭任务(_close_task,asyncio.create_task 创建恰一次、存于本层从不丢到后台、重复取消只重新 shield 同一任务)落成后才传播 CancelledError,资源恰关一次;_finish_close 里本层自有执行器 shutdown 改走 asyncio.to_thread,取消方不可能以同步 join 阻塞事件循环;调用方注入执行器仍由调用方持有,与总管脚本口径一致)。2) 所有权最小化——aclose 增加 owns_close 判定:只有真正取得 _aclose_lock 并置位 closing 的调用才可在仍可撤销(无 _close_task)时复位信号;等锁被取消的调用不改变持锁关闭者的任何状态。模块 docstring、aclose docstring、app lifespan 注释同步新协议口径。真崩溃语义不变(保守留账、只发无证明行、不宣称严格一次)。验证:python 3.11.16 venv + requirements.lock 离线 299 pytest 全过(新增 tests/test_rework_hel894.py 5 例,全部屏障驱动真实产品路径:提交阶段取消保持所有权并拒新工作零发送零计费/重复取消仍一次落成/同阶段第二调用等待后幂等返回且第三个等锁者取消不动状态/等锁者取消+持锁排空+新批 tick 拒绝+原 worker 完成组合/排空阶段取消仍可续用续跑),ruff 0 错(src/tests/tools);固定 mem0 2.2.1 确定性替身实跑 tools/verify_close_ownership_hel894.py 16/16(总管两负例同形:F1 提交取消 SDK-only——取消后 closing=true/closed=false/client 可用、取消方等关闭落成才返回、新批 tick 被拒(网关零到达、queued/owner NULL/attempts 0、llm_used=0)、放行后关闭恰一次、重开批次 queued 完好/row_done=0/llm_used=0;F2 +Store 关闭分支同形且无晚到错误;W 等锁者取消——closing 保持、新批 queued、原 worker 放行后 done/row_done=1、一次收尾);总管脚本原件在未改动 ceb0f35 上原样复跑基线与总管独立结果一致(before-ceb0f35.json),修复后原样复跑如实停在其自身前提断言 server.arrived(新协议下 tick 拒新领,前提结构性移除,verbatim-after-fix.log,原负例与基线保留不删);回归 verify_shutdown_queued_hel889.py 12/12、verify_inflight_lifecycle_hel886.py 6/6、verify_semantic_recovery_hel885.py 7/7、verify_mem0_real_hel874.py 12/12、check_release_offline_hel882.py R1–R7 15/15、总管 review_hel882_{partial,extra}.py 原样复跑通过、HEL-889 同形复跑通过;零真实 LLM/真实嵌入/非回环出站,权威三账与冻结余额未写,未部署未合并未交体验地址,不改视觉",
"acceptance": [
"负例一修复(固定 SDK 实跑,SDK-only 分支):真实 client.close 进入后取消 aclose——取消返回时 closing=true/closed=false/client 可用(不再宣称可续用);新批 tick 被拒:网关零到达、批次 queued/owner NULL/attempts 0、llm_used=0(修复前:closing=false + 新批被领 + QdrantLocal instance is closed + failed/row_done=0/llm_used=1);被取消调用方等层持有关闭任务落成后才传播(closed=true/client 不可用/live_workers=0/close 恰一次);重开批次 queued 完好、row_done=0、llm_used=0",
"负例一加强分支(调用方随后关 Store,单独记录不与 SDK-only 混淆):同上且无任何晚到错误(修复前 ProgrammingError: Cannot operate on a closed database,重开 pending/row_done=0/llm_used=1)",
"负例二修复(固定 SDK 实跑):第一 aclose 排空中、第二等锁即取消——closing 保持置位(修复前被清);新批 tick 被拒仍 queued;原 worker 放行后 done/row_done=1;第一关闭随后一次收尾关库;新批保持 queued",
"所有权完整回归(pytest 屏障驱动真实路径):排空取消可续用(closing 复位、后续批次正常跑完)、提交阶段取消不得半关可用、同阶段第二调用等待后幂等且一次关闭、重复取消仍一次落成、等锁者取消不动状态、并发关闭一次(HEL-889 既有用例保持全绿)、成功关闭拒新任务;原排队取消、活 worker 超时排空、行间续跑、处理中取消单发、全完成零预算收尾全部保持(299 pytest、shutdown-queued 12/12、inflight 6/6、recovery 7/7、contract 12/12、release R1–R7 15/15)",
"总管脚本原件保留:未改动 ceb0f35 上原样复跑基线与总管独立 JSON 一致(before-ceb0f35.json);修复后原样复跑停在其自身前提断言并如实存档(verbatim-after-fix.log);同形重跑断言按新安全协议改写并逐条注明(tools/verify_close_ownership_hel894.py,close-ownership-real-sdk.json 16/16)",
"工程检查:299 pytest(含 5 新例)全过、ruff 0 错(src/tests/tools);本卡未改前端、未重跑前端检查、不冒充历史数字;双目标需求检查 4/4(含本 handoff)"
],
"deferred": [
"发布与体验地址:由总管独立复审本 head 后交发布卡按 deploy/hel874-release.md 执行(8360 隔离实例);本卡未部署未合并 PR#11 未交体验地址",
"真实语义激活(CYBERGRIL_SEMANTIC=mem0):需 B 部分预算批准 + 3.11 mem0 栈 wheel 落位;未激活前 stub/FTS 不冒充真实记忆体验",
"A/B/C 执行表数值仍待批准建议:批准前所有 cap 保持 0=拒绝;新增预算由总管统一处理,不作为离线修复阻塞",
"真死进程『严格一次』不在宣称范围:远端无幂等支持时崩溃结果未知,恢复保守留账、只发无证明行(runbook §4 HEL-889/894 段已如实写明)",
"R5 语音 HEL-878/879、R6 天气/素材/完整备份、R7 有条件观察承接不变;视觉仍交原作者,本卡未改视觉;真实体验效果待体验地址交付后由白栖知判断"
],
"requirement_changes": [],
"verification": [
"分支 hel-870-assembly 追加提交(最终 head 见交付评论),PR#11 只追加未强推未合并;视觉总监分支未覆盖",
"python 3.11.16 venv + requirements.lock 离线:299 项测试全过(新增 tests/test_rework_hel894.py 5 例,全部屏障驱动真实产品路径,无预置死租约冒充活线程);ruff 0 错(src/tests/tools);本卡未改前端故未重跑前端检查,如实注明",
"固定 mem0 2.2.1 安装(hel857-venv 3.10.12)确定性替身实跑(docs/rework/hel894/):tools/verify_close_ownership_hel894.py 16/16(close-ownership-real-sdk.json,F1/F2/W 为总管两负例同形重跑,断言按新协议改写并注明);总管脚本基线原样复跑与独立结果一致(before-ceb0f35.json);修复后原样复跑停在自身前提断言(verbatim-after-fix.log)",
"回归:verify_shutdown_queued_hel889.py 12/12、verify_inflight_lifecycle_hel886.py 6/6、verify_semantic_recovery_hel885.py 7/7、verify_mem0_real_hel874.py 12/12、check_release_offline_hel882.py R1–R7 15/15、总管 review_hel882_{partial,extra}.py 原样复跑通过、HEL-889 同形复跑(review_hel886_edges_rerun_hel889.py)通过;review_hel885_inflight.py 本轮未重跑,其存档口径不变",
"python3 scripts/check_requirements.py --base-ref origin/main [--handoff docs/requirements/handoff-HEL-894.json] 与 --base-ref origin/agent/agent/de8874a3803b [--handoff …] 四项通过"
]
}