Files
CyberGril/docs/budget-package-hel895.md
T
zonggongandmultica-agent c121c42e39 HEL-896 release completion: the A/B/C budget becomes an executable two-instance split, the real-browser false positive is fixed precisely (product untouched), the SDK gap list is corrected to the honest 41-distribution closure with the pip-download erratum, and release archiving becomes a consistency snapshot - (1) budget split: the manager's independent review reproduced on a temp store that writing A's total_requests=55 into the shared product ledger blocks B's mem0_extract and C's dialogue_main with budget_total_requests_exhausted:55/55 while budget_total/request_usage/token_usage have no stage or authorization-source column; docs/budget-package-hel895.md gains §6 making the split executable: A lives ONLY on the isolated 8360 team-test instance with its own DB and models.yaml (55/500000 one-shot totals plus same-value daily category caps), the user instance NEVER carries one-shot totals (its budget_total rows are record-only, no gate), A is sealed by stop+consistent-snapshot archiving with budget_total never zeroed and restart/archive proving the seal holds, old test data has no import path into the user instance (release checklist forbids copying the 8360 data dir), B starts only after baiqizhi approval writes llm_cap/embed_cap per the 500+180 formula with the authority frozen prefix, the real-Mem0 smoke is counted INSIDE B's 60/180, B cap-hit queues batches (no retry burn, no lost rows, FTS fallback, chat uninterrupted) and first-week end requires a fresh approval to continue, and §6.4 gives one responsible limited recommendation (A 55/500k isolated, B 60 LLM/180 embeds, C daily table) plus errata for the two unsafe original claims ('A shares C's daily account' and 'WAL single file copies whole'); tools/verify_budget_split_hel896.py 8/8 on temp stores and stand-ins only (S0 exact-shape repro of the manager's finding, S1 team instance consumes the §1 step plan to 55 then hard-stops with the tightest gate winning - life daily 8/8 rejects before the total, S2 seal survives restart and backup-API archive, S3 user instance B/C unblocked after A with dialogue 60/semantic 40/daily-token stacking and rejections booking nothing, S4 the misconfigured-total guard on the user instance, S5 repo configs and authoritative facts untouched, real caps all stay 0); (2) browser false positive fixed without touching any product file: web/tests/hel895_real.mjs B3 used '!!stage || any visible button' and clicked the FIRST button containing 回 which is the 日子与回忆 home nav button, so stage=false still PASSed and the screenshot stayed on days - the verbatim original rerun reproduces the false 7/7 with B3 stage=false (docs/rework/hel896/browser-before/), and the revised test passes 9 checks by precise interaction: B2 asserts the letter card carries her exact words plus the talk-nav unread aria-label, B3a waits for the VISIBLE reach card (aside.reach.show, aria-hidden=false, non-zero box, exact words) over days, B3b clicks only THAT card's 回她 button and strictly asserts the conversation stage .conversation .sr contains the reach-out text with the unread mark cleared, B4/B5 prove dedup by server message id (data-mid in the record panel: zero duplicates, gap and live reach-outs each exactly once), B5 asserts /api/health epoch bumps exactly +1 (1->2) before rechecking, B6 counts the page's OWN permissions.query/getUserMedia calls from first document load (0/0, instrumented via Page.addScriptToEvaluateOnNewDocument after Page.enable), B7 runs the service under a temp loopback models config (CYBERGRIL_MODELS, all caps 0) plus a sitecustomize socket guard that REJECTS and eagerly reports non-loopback connects (0 attempts, 0 non-loopback DNS lookups, report survives signal death) - under precise interaction the stage really plays, unread really clears, dedup and epoch semantics really hold: it was a test defect, not a product defect, so no interface change and nothing to escalate; (3) SDK honesty: tools/audit_sdk_offline_hel896.py (read-only, zero downloads/installs/inference) computes the 3.11-Linux closure from the installed 3.10 pinned metadata - 55 dists, 41 missing from the product venv (28 pure + 13 native incl. grpcio/numpy/onnxruntime/tokenizers/sqlalchemy/protobuf), all three top-level pins are py3-none-any (no 'cp311 wheel' needed for them), mem0ai's installed direct_url is the local fixed source hel857-src and hel857-data/mem0-2c81af3.tar.gz hashes exactly to the lock's 9dcef930...dda23 (an index mem0ai==2.2.1 wheel proves nothing), the wheel built during hel857 lived only in an ephemeral cache and hatchling is not offline-available, exactly 3 of the 41 are cache-reusable today for 3.11 (greenlet 3.5.6 cp311, pillow 12.3.0 cp311, truststore 0.10.5 py3-none-any - version+tag verified), the fastembed model cache is measured (Qdrant/bge-small-zh-v1.5 + bm25, ~92MB, placement = instance data dir copy), and the seq48-51 pip event is settled by cache forensics: uv's pip-26.2.2 wheel entry (files.pythonhosted.org, sha256 fd7f4dfa...) was CREATED 2026-10-27 02:10:04 inside the HEL-895 run window as the ONLY new cache entry, so that step DID fetch from the network - the prior card's zero-download claim is corrected to 'download' by the conservative reading (byte-level download vs conditional request is indistinguishable from cache evidence) while the lock install itself added no new cache entries; deploy/hel895-release-candidate.md §4 is rewritten to this accurate list, all future installs forced offline/no-index; (4) release archiving: tools/release_snapshot_hel896.py implements the two safe modes (stop+wal_checkpoint(TRUNCATE)+copy, or online SQLite backup API), writes per-file sha256 manifests carrying the exact code commit, per-table row-count verification and a verify-mode rollback drill; its selftest reproduces the manager's WAL finding (online naive copy of the main .db: 'no such table: companion') and proves both fixed modes complete (backup API and checkpoint copies both hold companion=1/chat_message=1, archive hashes+rows verify, commit 04eff61 recorded); §5 of the release doc now carries the copy-paste commands covering the product DB, semantic vector root, history root and the authoritative embed ledger, archives are never deleted, and the section explicitly does NOT claim R6 complete backup; regression on this head: pytest 299/299 (3.11.16 venv + requirements.lock offline), ruff clean (src/tests/tools), web typecheck 0 errors / lint 0 errors 1 pre-existing warning / vitest 55/55 / build passes with CSS still index-DdDYzR5S.css, pinned-SDK reruns all green (close-ownership 16/16, shutdown-queued 12/12, inflight 6/6, semantic-recovery 7/7, mem0-real 12/12, reports in docs/rework/hel896/regression/), check_release_offline R1-R7 passes, real-HTTP pagination 7/7 rerun saved as docs/rework/hel896/http-pagination-rerun.json with the original hel895 evidence byte-untouched, requirement checks 6/6 (origin/main, de8874a3803b, 152479b, each with and without handoff-HEL-896.json); handoff-HEL-896.json written; zero real LLM, zero real embeddings, zero new downloads beyond existing caches, authoritative ledgers and freezes (39/60, 498/500, 2 frozen, HEL-835 gate) untouched, not deployed, PR#11 appended-not-merged, no visual changes, R5/R6/R7 honestly deferred
Co-authored-by: multica-agent <github@multica.ai>
2026-10-27 03:06:23 +08:00

13 KiB
Raw Blame History

HEL-895 · 真实全链一次批准执行包(A/B/C 合并核定稿;仍全部待授权,默认 0 不变)

HEL-896 分账修订(2026-10-27):总管独立复审证实,若按本文件 §1 原表把 A 的 total_requests=55 写进与 B/C 共用的产品库,B 的 mem0_extract 与 C 的 dialogue_main 在 A 用满 55 次后都被 budget_total_requests_exhausted:55/55 挡死 (复现 tools/verify_budget_split_hel896.py S0;账表也无阶段/授权来源字段)。 执行口径改为 §6:A 落在独立团队测试实例自己的库,B/C 落在全新用户实例的库, 用户实例永不配置一次性总量。 §1–§5 与本修订冲突处以 §6 为准;四道闸叠加、 保守入账、碰顶停机等语义不变。

本文件把 docs/budget-plan-hel874.md 的 A/B/C 三表收拢成一次可批准的具体执行包: 每一步的请求/嵌入/失败-取消-重试上限、累计与日顶的叠加口径、一次性团队检查与用户 日常使用的分账、碰顶停机语义与留证方式。技术核对基于本卡实际代码与配置 (src/cybergril/life/model.py 的 PersistentBudget、src/cybergril/think/budget.py、 config/models.yaml、config/semantic.example.yaml、299 pytest 含 tests/test_hard_gates_hel882.py)。

批准状态:三部分均未批准。随包 models.yaml 全部上限为 0(未批准即发送前拒绝), semantic.example.yaml 缺省全 0。本卡零真实调用、零真实嵌入、零权威账写入。 旧账 39/60(真实请求)与 498/500(嵌入,冻结 2 条)及 HEL-835 闸原样保全, 不挪用、不重置、不并入。真实数值只有白栖知批准后由总管写入。

1. 批准项(一个包,三个独立账)

部分 用途 硬顶(批准后由总管写入) 账本(HEL-896 修订:见 §6 实例分账)
A · 一次性团队整体检查 8360 隔离实例按体验链 1–7 全链走一遍(stub 语义,零嵌入) 总量 55 次请求 / 500,000 tokens / 0 嵌入(budget.total_requests/total_tokens,跨日累计)——只写团队实例自己的库 团队实例库的 budget_total/request_usage/token_usage
B · 首周语义激活 CYBERGRIL_SEMANTIC=mem0 真实激活观察 提取 LLM ≤60 次(llm_cap);嵌入 ≤180 条新批 → 按算式写 embed_cap=680、embed_reserve=2(权威账已用 498/原批 500) llm_ops(新表)/embed_ops(权威账续账,authority 冻结前缀必填)
C · 用户日常使用 体验地址交付后每日 dialogue ≤60/日、life ≤8/日、background ≤40/日、semantic ≤40/日(daily_requests);嵌入 ≤60 条/日(embed_daily);tokens ≤2,000,000/日(daily_tokens,全类别共池) 用户实例库的持久表 + 日顶列(不配置一次性总量)

【HEL-896 勘误】原文「A 当天同时受 C 类日顶约束」按共用产品账本表述,会把 A 的消费 算进用户的日账并让 A 的 55 总量挡住 B/C;修订后 A 在自己的实例与账本内受同数值的 类别日顶约束(§6 S1 验证:life 日顶 8/8 先于总量拒绝、semantic 余量内由总量拒绝—— 叠加取最紧),与用户实例日账互不相干。B 期间的对话/生活/判定请求并入 C 日账, 不占 B 的 60 次。三部分独立授权来源保持:A 需总管新批(产品环境网关用量不属于 HEL-857 的 60 次实验授权);B/C 需白栖知明确批准。

2. 叠加口径(逐笔发送前原子预占;总管核定值写入后自动生效)

一次真实 provider 发送(创建/对话/生活/gist/判定/成长/主动措辞/Mem0 内部提取) 在 PersistentBudget.acquire 同时过四道闸,任一到顶即 BudgetStop 拒绝,不降档续调:

  1. 类别日顶(该调用所属 daily_requests 类别:dialogue/life/background/semantic);
  2. 日 token 池(daily_tokens,全类别共池;70% 警告、95% 非关键场景 structured 预检先停);
  3. A 部分一次性总量(total_requests/total_tokens,跨日累计,重启不归零);
  4. B 部分类别账:Mem0 内部提取 LLM 另过 llm_cap 累计 + llm_daily;嵌入过 embed_cap 累计(含冻结 embed_reserve)+ embed_daily。

交叉核对结论(本卡逐项核过代码与测试):

  • 交叉(有意叠加,非重复计费):A 的每次请求同时计入 A 总量与当天类别日顶; B 的每次提取 LLM 同时计入 llm_ops 累计与 semantic 日顶 + 日 token 池。两处计数 用途不同(一个限一次性总量/首周观察,一个限每天),不会互相退款或放宽。
  • 不重复:嵌入只记 embed_ops(条数),不进请求计数;提取 LLM 只在 llm_ops+统一请求闸各记一次;主对话与语义层各自独立闸(tests/ 双实例同库复现)。
  • 不漏记:四个请求类别(dialogue/life/background/semantic)+ 嵌入 + 全池 token 已覆盖全部产品出站点;SDK 隐藏重试已禁用(max_retries=0),每次实际发送都过闸。

3. 失败、取消与重试(保守入账,不退款)

  • 发送前预占(请求次数 + 保守 token 估算:输入字符 1:1 + 声明 max_tokens 全额); provider 返回真实 usage 按实际修正(多补少退)。
  • 未知 usage/断流/失败/取消保守保留全部预占;已发送的成本不当未发生。唯一释放 路径是可证明未连接(httpx.ConnectError 级)的显式 release()。
  • 真实错误重试 ≤3 次/批;预算拒绝不耗重试次数——作业回 queued (reason=semantic_*_budget_*),总管调 cap 后同批续跑,已完成行不重发。
  • 嵌入:单条失败释放;批次中途失败整批保守落账。

4. 碰顶停机语义与留证

  • 全部硬闸在发送前拒绝(budget_*_exhausted / semantic_*_budget_*),拒绝如实 记录,不补发、不换渠道。
  • 语义层到顶只停语义(检索回落词面 FTS,主对话不中断);日 token 到顶停当日全部 真实调用;A 总量到顶即团队检查收尾。
  • 留证:budget_total/request_usage/token_usage/embed_ops/llm_ops 表 + 服务日志 + 隔离实例数据目录(【HEL-896 勘误】在线库直接复制主 .db 会丢 WAL 中 已提交行——归档一律停服务+checkpoint 或 SQLite backup API 一致性快照,见 tools/release_snapshot_hel896.py 与 deploy/hel895-release-candidate.md §5); 碰顶当时的拒绝 reason 与计数快照截图/导出一并归档到交付评论。

5. 本包默认状态(本卡随包可执行)

config/models.yaml:daily_tokens: 2000000(结构性默认值,非授权)、 daily_requests.* 全 0、A 部分总量两行保持注释(待批);config/semantic.example.yaml 全部 cap/daily 为 0、authority 必填结构就位。未写入批准值前,任何创建/对话/ 生活/gist/判定/成长/主动措辞/提取调用都在发送前被硬闸拒绝(budget_*_exhausted), 这是设计行为;已由 tools/check_release_offline_hel882.py R3 与 299 pytest 复现。

6. HEL-896 可执行分账与阶段切换(独立团队测试实例 + 全新用户实例)

本节把 A/B/C 落成可直接执行的实例/账本拆分;全部语义由 tools/verify_budget_split_hel896.py 在临时库+替身上验证(零 provider、零真实 cap 变更,证据 docs/rework/hel896/budget-split/budget-split.json)。不新造预算引擎, 不改表结构:budget_total/request_usage/token_usage 无阶段字段这一事实, 正是用实例隔离代替字段拆分的理由。

6.1 实例与账本拆分

团队测试实例(A) 用户实例(B/C)
形态 8360 端口隔离 systemd 单元(deploy/cybergril-hel874-8360.service.example 模式),独立数据目录 发布候选部署的全新实例,全新空库(用户自己创建唯一真实档案)
models.yaml total_requests: 55、total_tokens: 500000 + 当日类别日顶(同 C 表数值)+ daily_tokens 永不配置 total_requests/total_tokens(保持注释/缺省);只写 C 表日顶;budget_total 行仅作流量记录,无总量闸(S3 验证)
语义层 CYBERGRIL_SEMANTIC=stub(零嵌入、零真实 Mem0) B 批准后 =mem0;embed_cap/llm_cap/embed_daily/llm_daily 只在白栖知批准后由总管写入 config/semantic.yaml(含 authority 冻结前缀)
账本 自己的 SQLite(budget_total 等);封账后归档留存 自己的 SQLite 日账 + 权威 embed_ops 续账(498/500 + 冻结 2 条原样)
授权来源 总管新批(产品环境网关用量,不属于 HEL-857 60 次实验授权) B/C 均需白栖知明确批准(一次批准包 = 本文件)

误配守门:用户实例若误写 total_requests,A 型堵死会立刻复现(S4)——发布卡 部署检查单必须逐项核对用户实例 models.yaml 无一次性总量两行、团队实例配置只存在 于 8360 数据目录。

6.2 A 的执行与封账

  1. 总管批准后写入团队实例 models.yaml(仅该实例),按 docs/budget-plan-hel874.md §1 体验链 1–7 逐步执行:创建/诠释/习惯 4、对话 16、 生活 8、判定/成长/gist 20、主动措辞 3,其余额度备用至 55;每步在四道闸下原子 预占(类别日顶→日 token 池→一次性总量;S1 验证叠加取最紧)。
  2. A 结束即封账,两种到达方式同义:额度用满(budget_total_requests_exhausted:55/55 如实拒绝、不补发)或体验链走完。封账动作:systemctl stop 8360 实例 → tools/release_snapshot_hel896.py 做一致性快照(停服+checkpoint/backup API)→ 归档(数据目录 + 哈希清单)交交付评论。封账跨重启、跨归档不失效(S2 验证), budget_total 永不手工清零。
  3. 旧测试数据不会转成用户伴侣:测试档案、聊天、生活数据只存在于团队实例库与 归档;用户实例是全新空库,由用户自己创建档案;产品无任何「测试库导入用户库」 路径,发布卡明令禁止把 8360 数据目录复制/合并进用户实例数据目录。
  4. 后续任何团队复检 = 新批准 + 新实例/新库(或在 8360 实例上以新批准抬 total_requests),绝不续在用户账上。

6.3 B/C 的开始与日常

  1. B 开始的配置与授权:白栖知批准后,总管把 llm_cap: 60、按算式 embed_cap: 680、embed_reserve: 2、llm_daily/embed_daily(C 表值)与 authority(权威账前缀逐行摘要 + min_used: 498)写入用户实例 config/semantic.yaml,CYBERGRIL_SEMANTIC=mem0 生效;缺/错 authority 在构造前 fail-closed(HEL-885 既有验证,不在本卡重复)。
  2. 真实 Mem0 冒烟与 B 首周的关系:A 的 stub 检查证明产品链路零语义也能走通; B 激活当天先做真实 Mem0 冒烟(数条 add/search/原话回读),其 LLM/嵌入消费 全部计入 B 的 llm_ops/embed_ops(即 60/180 的一部分,不另设隐藏额度),冒烟 通过即进入首周观察;B 期间用户对话/生活/判定照走 C 日账,与 B 的累计账并行不占额。
  3. B 到顶的停/续语义:任一 cap 到顶 → 作业批回 queued (reason=semantic_*_budget_*)不丢行不耗重试,语义层停(检索回落词面 FTS, 主对话不中断);续跑唯一路径 = 新批准按算式抬 cap(embed_cap = 原上限 + 新增量),总管写入后同批续跑,已完成行不重发。无新批准则语义层停在原地, 不自动翻页、不挪用 C 额度、不动冻结余额。
  4. 首周结束的停/续语义:7 天观察期满,总管导出 llm_ops/embed_ops/日账实际 用量与质量观察报告交白栖知;未获新批准,B 保持当时 cap(用尽即停语义), C 日常照常;获批续期则按新算式写新 cap。B 与 C 无任何自动转换或继承。
  5. 全局累计与日顶的叠加(仅用户实例内部):每笔真实发送四道闸原子预占、取最紧 (类别日顶 → 日 token 池 → B 的累计 cap×2 → embed/llm 日顶);A 的总量闸不在 用户实例存在(S3/S4 验证两侧)。39/60(HEL-857 真实请求旧账)与 498/500、冻结 2 条、HEL-835 闸是历史授权事实记录,不属于任何实例配置,本轮零改动(S5)。

6.4 一次负责的有限推荐(供总管一次性向白栖知申请;默认值不变)

  • A(总管权限内新批):55 次请求 / 500,000 tokens / 0 嵌入,仅 8360 团队实例, 体验链走完即封账归档。
  • B(白栖知批准):提取 LLM 累计 60 次;嵌入新增 180 条(embed_cap=680、 embed_reserve=2 续权威账);llm_daily=40、embed_daily=60;首周观察,期满 凭实际用量报告决定停/续。
  • C(白栖知批准):dialogue 60/日、life 8/日、background 40/日、semantic 40/日; 嵌入 60 条/日;tokens 2,000,000/日。
  • 推荐理由:A 按体验链实测上界+备用;B 按 HEL-874 实测单次开销(add 1 LLM + 2–3 嵌入)对 60 次提取 ≈ 最多 180 条嵌入;C 按生活槽 4/天与 60 轮对话日常上界。 真实失败/取消保守入账不退款、重试 ≤3 次/批(§3)不额外放大。
  • 三笔互相独立、逐笔硬闸、默认 0;未批准部分保持 fail-closed,不因其余获批自动放开。