HEL-879 release closure: the four HEL-896 audit findings become enforced behavior - (1) archive consistency: tools/release_snapshot_hel896.py v2 checks the wal_checkpoint(TRUNCATE) return (busy!=0 = hard failure, no deliverable tar, half-built dir removed - 'stopped service first' is a precondition, never a reason to ignore an actual failed result), aborts packaging on any source-vs-snapshot table-count mismatch instead of recording rows_match=False and shipping anyway, and verify_archive now rejects legacy packages that recorded rows_match=False while mapping a real rollback drill (unpack to an isolated dir, open every DB, check rows AND hashes against both recorded source and snapshot counts, emit a source-path rollback_plan - no more tar-internal self-attestation); selftest 9/9 reproduces every old failure shape first (naive WAL copy loses companion, held-reader checkpoint=(1,9,8) leaves the copied image malformed/missing the events row, the manager's rows_match=False legacy package verifying ok) then proves each fix (busy fails with zero artifacts, stale-snapshot mismatch fails with zero artifacts, online mode refuses --file dirs containing SQLite by magic-header scan, stop mode recursively takes embedded SQLite like history_root/mem0_public_history.db through checkpoint+per-table verification, verify maps source paths and passes); (2) early-finish seal: PersistentBudget gains sealed()/seal() writing sealed/sealed_requests/sealed_tokens/sealed_at atomically into budget_total beside the real usage (never faking 55, never zeroing), acquire checks the seal FIRST so every category and every remaining allowance rejects budget_sealed:51/55, the marker survives restart and backup-API archive/restore, reseal is idempotent, and there is deliberately no unseal path (re-test = new approval + new instance per budget-package 6.2.4); tools/seal_budget_hel879.py makes the closure an explicit auditable operator command with a post-seal rejection self-check; verify_budget_split_hel896.py gains S6 (51/55 experience chain completes -> seal keeps usage 51 -> 52nd and cross-category rejected with dialogue daily still 19/60 proving it is the seal not the caps, mistaken restart rejected, archive restore rejected, marker requests=51 intact) now 10/10, HEAD made dynamic instead of hardcoded 04eff61; budget-package-hel895.md 6.2 rewritten to the executable seal order (stop -> seal -> consistency snapshot); (3) single install entry: deploy/hel895-release-candidate.md 2 is now the only copy-paste install (uv --offline, npm --offline, cache-miss = stop and record, network only inside an authorized release window with per-item sha256) and 4 is the only fixed-SDK entry as a five-step chain (verify tarball sha256 9dcef930...dda23 against mem0-stack.lock -> build the wheel from the fixed source with hatchling honestly listed as the missing build backend -> cp311 dependency prep with greenlet/pillow/truststore confirmed cache-reusable on re-run -> local-wheels-only --no-index install where mem0ai must come from the fixed-source wheel, the lock line is version-only -> same-process co-import plus the 92MB fastembed cache placement); deploy/hel874-release.md 2/4 carry superseded banners pointing here, mem0-stack.lock no longer routes installs through the index mem0ai==2.2.1 wheel; (4) exact-commit honesty: audit_sdk_offline_hel896.py derives head from git rev-parse and accepts an output dir, fresh evidence written to docs/rework/hel879/sdk-audit/ (hel896 evidence left untouched) recording closure 55 / missing 41 (28 pure + 13 native) / cache-reusable [greenlet, pillow, truststore] / tarball-matches-lock at c121c42; regression on this head: pytest 299/299, ruff clean (src/tests/tools), release-snapshot selftest 9/9, budget-split 10/10 including the new S6 negatives; zero provider calls, zero downloads, authoritative ledgers/freezes/HEL-835 gate untouched, not deployed, PR#11 untouched
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
multica-agent
parent
c121c42e39
commit
01ff919859
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""HEL-896 · A/B/C 分账与阶段切换验证(仅临时库 + 替身,零 provider、零网络)。
|
||||
"""HEL-896/879 · A/B/C 分账、阶段切换与提前封账验证(仅临时库 + 替身,零 provider、零网络)。
|
||||
|
||||
总管独立复审(HEL-896 附件 §1)复现的问题:把 A 的一次性总量 55 写进与 B/C 共用的
|
||||
产品库 PersistentBudget 后,B 的 mem0_extract 与 C 的 dialogue_main 都被
|
||||
@@ -12,6 +12,9 @@ budget_total_requests_exhausted:55/55 挡住,且 budget_total/request_usage/to
|
||||
S2 封账 —— 重启不归零;SQLite backup API 一致性快照归档后,归档件
|
||||
仍是 55/55 且继续拒绝(封账跨重启、跨归档成立);测试档案
|
||||
只留在团队库;
|
||||
S6 提前封账(HEL-879) —— 体验链 51/55 走完即显式 seal:真实用量保留 51(不伪造
|
||||
55、不清零),第 52 次任何类别拒绝 budget_sealed:51/55;
|
||||
误重启、backup API 归档恢复后同样拒绝;seal 幂等不覆盖;
|
||||
S3 全新用户实例(B/C) —— 独立新库、不配置一次性总量:A 耗尽后 B(mem0_extract)
|
||||
与 C(dialogue_main)照常放行;日顶叠加(dialogue 60、
|
||||
semantic 40、daily_tokens)逐项到顶拒绝;拒绝不落账;
|
||||
@@ -32,6 +35,7 @@ from __future__ import annotations
|
||||
import hashlib
|
||||
import json
|
||||
import sqlite3
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
@@ -42,7 +46,18 @@ from cybergril.life.model import PersistentBudget # noqa: E402
|
||||
from cybergril.memory.store import Store # noqa: E402
|
||||
from cybergril.think.budget import BudgetConfig, BudgetGuard, BudgetStop # noqa: E402
|
||||
|
||||
HEAD = "04eff611e7d85e539d43717711172441420ac853"
|
||||
REPO = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def git_head() -> str:
|
||||
try:
|
||||
return subprocess.run(["git", "rev-parse", "HEAD"], cwd=REPO, capture_output=True,
|
||||
text=True, check=True).stdout.strip()
|
||||
except Exception:
|
||||
return "unknown"
|
||||
|
||||
|
||||
HEAD = git_head()
|
||||
RESULTS: list[tuple[str, bool, str]] = []
|
||||
|
||||
|
||||
@@ -150,6 +165,61 @@ def main() -> int:
|
||||
team_reopened.close()
|
||||
sealed.close()
|
||||
|
||||
# ── S6:提前封账(HEL-879)——体验链 51/55 走完即 seal,误重启/归档恢复均拒绝 ──
|
||||
early = Store(tmp / "team-8360-early.db")
|
||||
early_cfg = BudgetConfig(daily_tokens=2_000_000,
|
||||
daily_requests={"dialogue": 60, "life": 8, "background": 40, "semantic": 40},
|
||||
total_requests=55, total_tokens=500_000)
|
||||
early_guard = PersistentBudget(early, BudgetGuard(early_cfg))
|
||||
# A 表 51 次(创建/诠释/习惯4 + 对话16 + 生活8 + 判定/成长/gist20 + 主动措辞3)
|
||||
# 就是体验链全部内容——走完即停,不补到 55。
|
||||
early_plan = [("fact_extract", 4), ("dialogue_main", 16), ("life_event", 8),
|
||||
("memory_gist", 20), ("proactive_message", 3)]
|
||||
early_ok = True
|
||||
for scene, n in early_plan:
|
||||
for _ in range(n):
|
||||
early_ok &= acquire(early_guard, scene) == "allowed"
|
||||
used_before_seal = early_guard.total_requests_used()
|
||||
marker = early_guard.seal()
|
||||
s6_52nd = acquire(early_guard, "dialogue_main")
|
||||
s6_other_scene = acquire(early_guard, "mem0_extract")
|
||||
s6_daily_still_has_room = early_guard.requests_used("dialogue") # 19/60:日顶有余
|
||||
check("S6a_early_finish_51_seals_real_usage_no_fake_no_zero",
|
||||
early_ok and used_before_seal == 51 and marker["requests"] == 51
|
||||
and s6_52nd.startswith("budget_sealed:51/55") and s6_other_scene.startswith("budget_sealed:51/55")
|
||||
and early_guard.total_requests_used() == 51 and s6_daily_still_has_room == 19,
|
||||
f"used={used_before_seal} dialogue_next={s6_52nd} semantic_next={s6_other_scene} "
|
||||
f"after={early_guard.total_requests_used()} dialogue_daily={s6_daily_still_has_room}/60")
|
||||
# seal 幂等:重复 seal 不覆盖原标记(sealed_at 不变)。
|
||||
again = early_guard.seal()
|
||||
idempotent = again == marker
|
||||
# 误重启:重开库后第 52 次仍拒绝。
|
||||
early.close()
|
||||
early_reopened = Store(tmp / "team-8360-early.db", init=False)
|
||||
early_guard2 = PersistentBudget(early_reopened, BudgetGuard(early_cfg))
|
||||
s6_after_restart = acquire(early_guard2, "dialogue_main")
|
||||
# 归档恢复:backup API 归档封账库 → 打开归档件 → 同样拒绝,用量仍 51。
|
||||
early_archive = tmp / "team-8360-early-sealed.db"
|
||||
snapshot_via_backup_api(tmp / "team-8360-early.db", early_archive)
|
||||
early_arch = Store(early_archive, init=False)
|
||||
early_arch_guard = PersistentBudget(early_arch, BudgetGuard(early_cfg))
|
||||
s6_after_archive = acquire(early_arch_guard, "dialogue_main")
|
||||
arch_marker = early_arch_guard.sealed()
|
||||
check("S6b_seal_survives_restart_and_archive_restore",
|
||||
idempotent and s6_after_restart.startswith("budget_sealed:51/55")
|
||||
and s6_after_archive.startswith("budget_sealed:51/55")
|
||||
and early_arch_guard.total_requests_used() == 51
|
||||
and arch_marker is not None and arch_marker["requests"] == 51,
|
||||
f"restart={s6_after_restart} archive={s6_after_archive} "
|
||||
f"arch_used={early_arch_guard.total_requests_used()} marker={arch_marker}")
|
||||
report["scenes"]["S6_early_seal"] = {
|
||||
"plan_total": sum(n for _, n in early_plan), "used_at_seal": used_before_seal,
|
||||
"marker": marker, "next_after_seal": s6_52nd, "other_scene_after_seal": s6_other_scene,
|
||||
"after_restart": s6_after_restart, "after_archive_restore": s6_after_archive,
|
||||
"idempotent_reseal": idempotent}
|
||||
early_reopened.close()
|
||||
early_arch.close()
|
||||
|
||||
# ── S3:全新用户实例(B/C)——独立新库、无一次性总量:A 耗尽后 B/C 照常放行,日顶叠加 ──
|
||||
user = Store(tmp / "user-fresh.db")
|
||||
user_cfg = BudgetConfig(daily_tokens=2_000_000,
|
||||
|
||||
Reference in New Issue
Block a user