From 0b24fefc5daca9c54d96e7d2846093b5c75a7136 Mon Sep 17 00:00:00 2001 From: zonggong Date: Sat, 24 Oct 2026 14:49:06 +0800 Subject: [PATCH] HEL-835: synthetic retrieval probe seed script and runbook (approved plan, zero model calls) Co-authored-by: multica-agent --- docs/r3/PROBE-runbook-HEL-835.md | 30 +++++++++++++ docs/r3/probe-seed-HEL-835.py | 75 ++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 docs/r3/PROBE-runbook-HEL-835.md create mode 100644 docs/r3/probe-seed-HEL-835.py diff --git a/docs/r3/PROBE-runbook-HEL-835.md b/docs/r3/PROBE-runbook-HEL-835.md new file mode 100644 index 0000000..58989ad --- /dev/null +++ b/docs/r3/PROBE-runbook-HEL-835.md @@ -0,0 +1,30 @@ +# HEL-835 合成检索 probe 运行册(明日与隔天提问同批执行,已批复) + +## 前置(2026-10-24 已完成,零模型调用) + +- `docs/r3/probe-seed-HEL-835.py` 在隔离库 `/opt/cybergril-hel835-data/probe/seed.db` 直插:1 条目标记忆(巷口旧书店蓝灰色封面诗集,~26h 前,手写 gist)+ 20 轮合成近窗填充(同关键词、与诗集无关、手写 gist);`seed-info.json` 记目标 turn/memory id。**不在 8350 生产库填充;零模型调用。** +- 批复约束:不另开 synthetic_retrieval_probe 类别;唯一真实 DIALOGUE_MAIN 消耗本卡 6 轮中 1 次;与 8350 **共用同一权威账** `/opt/cybergril-hel835-data/guard-ledger.json`;probe 服务用独立进程/端口 8351/隔离库;真实 chat 成功产生的最多 2 次 gist + 1 次成长提取逐笔计入权威账。 + +## 明日执行顺序(优先保隔天提问) + +1. **先做 8350 真实隔天提问**(1 次 DIALOGUE_MAIN + 最多 2 次 gist + 1 次成长):自然提及诗集,记录 SSE、检索日志 hits(预期窗口内不注入)、账本。 +2. **余量检查**:若 dialogue_main<6 且 memory_gist≤6,启动 probe(步骤 3);否则停止 probe,把余量留给后续真实提问并回报。 +3. **probe**: + ```bash + cd /opt/cybergril-hel835/current + CYBERGRIL_DB=/opt/cybergril-hel835-data/probe/seed.db \ + CYBERGRIL_MODELS=/opt/cybergril-hel835/current/config/models.yaml \ + CYBERGRIL_HOST=127.0.0.1 CYBERGRIL_PORT=8351 CYBERGRIL_R2_ENABLED=0 \ + CYBERGRIL_GUARD_LEDGER=/opt/cybergril-hel835-data/guard-ledger.json \ + .venv/bin/python -m deploy.hel835_guard # 前台临时进程,测完 Ctrl-C / kill + ``` + - R2 关闭仅限 probe 进程(生产 8350 仍开),避免 probe 侧生活循环消耗类别外调用。 + - POST /api/chat「还记得我在旧书店买的那本诗集吗」→ 保存 SSE、journal `cybergril.memory.episodic` hits 行(应含目标 memory id、不含近20轮 turn)、mode。 + - 断言:响应自然提及诗集;隔离库底色指纹前后不变;权威账 dialogue_main +1、(成功后至多)memory_gist +2、growth_extract +1。 + - 杀掉 8351 进程(先比对 PID 非 multica daemon)。 +4. 合成消息/手写 gist 与模型产物在证据中分开标注;不改时钟、不改检索窗口、不塞答案。 +5. 若重试消耗余量:优先保留剩余真实提问额度,停止 probe 并如实回报。 + +## 边界 + +真实隔天回答只证明跨自然日近期上下文连续;probe 证明真实模型路由下近20轮外检索注入工程链路;两者都不是自然积累的真实长期记忆隔天取回——该项保留待验、另卡承接,不据此 in_review/done。 diff --git a/docs/r3/probe-seed-HEL-835.py b/docs/r3/probe-seed-HEL-835.py new file mode 100644 index 0000000..cc26f1f --- /dev/null +++ b/docs/r3/probe-seed-HEL-835.py @@ -0,0 +1,75 @@ +"""HEL-835 synthetic-retrieval probe: seed an ISOLATED db (zero model calls). + +Reviewer-approved plan (2026-10-24): 21+ synthetic old turns SQL-seeded with +handwritten gists; the single real DIALOGUE_MAIN call happens TOMORROW in the +same limited batch as the day-2 real question, against a throwaway service on +port 8351 that shares the ONE authoritative guard ledger. This script only +seeds and verifies - it never starts a service and never calls any model. + +Run (server): cd /opt/cybergril-hel835/current && .venv/bin/python \ + docs/r3/probe-seed-HEL-835.py /opt/cybergril-hel835-data/probe/seed.db +""" +import json +import sys +import time +from pathlib import Path + +from cybergril.memory.store import Store + +# Synthetic story: turn 0 holds the target memory (old poetry-collection chat); +# turns 1..20 are recent-window filler turns also mentioning the keyword, so a +# real retrieval must come from OUTSIDE the last-20-turn window by design. +TARGET_TURN = "00000000-probe-0000-4000-8000-000000000000" +FILLER_TURNS = [f"00000000-probe-0000-4000-8000-{i:012d}" for i in range(1, 21)] +TS0 = int(time.time() * 1000) - 26 * 3600 * 1000 # ~26h ago, before recent window + + +def seed(db_path: Path) -> dict: + db_path.parent.mkdir(parents=True, exist_ok=True) + if db_path.exists(): + db_path.unlink() + with Store(db_path) as store: + with store.conn: + store.execute("INSERT INTO companion(name,birth,hour,relation,nickname,boundary)" + " VALUES('小满','2001-05-21','午时','朋友','','尊重彼此的节奏')") + rows = [] + # Target old turn (outside the 20-turn window). + store.execute("INSERT INTO chat_message(ts,role,text,turn_id,status) VALUES(?,?,?,?,'sent')", + (TS0, "user", "我今天在巷口旧书店买了一本蓝灰色封面的诗集。", TARGET_TURN)) + rows.append(("user", "我今天在巷口旧书店买了一本蓝灰色封面的诗集。", + "用户在巷口旧书店买了一本蓝灰色封面诗集。", TARGET_TURN)) + # Filler turns inside the recent window, same keyword, no poetry books. + for i, turn in enumerate(FILLER_TURNS, start=1): + text = f" filler topic {i}:雨天通勤和晚饭。" + store.execute("INSERT INTO chat_message(ts,role,text,turn_id,status)" + " VALUES(?,?,?,?,'sent')", (TS0 + i * 60000, "user", text, turn)) + rows.append(("user", text, f"合成填充第{i}轮:与诗集无关。", turn)) + for role, raw, gist, turn in rows: + store.execute( + "INSERT INTO mem_episodic(role,raw,gist,salience,affect,source,accessibility," + "turn_id,message_id,created_at) VALUES(?,?,?,0.5,NULL,'chat',1,?,NULL,?)", + (role, raw, gist, turn, TS0), + ) + store.execute("INSERT INTO life_control(key,value) VALUES('memory_search','on')") + ids = {r["turn_id"]: r["id"] for r in store.query("SELECT id,turn_id FROM mem_episodic")} + n_msg = store.query_one("SELECT count(*) n FROM chat_message")["n"] + n_mem = store.query_one("SELECT count(*) n FROM mem_episodic")["n"] + return {"target_turn": TARGET_TURN, "target_memory_id": ids[TARGET_TURN], + "messages": n_msg, "memories": n_mem} + + +def main(): + db_path = Path(sys.argv[1]) + info = seed(db_path) + info["seeded_at"] = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) + info["note"] = ("Synthetic fill for the approved retrieval probe. Handwritten gists, zero model " + "calls; target memory sits OUTSIDE the last-20-turn window by construction. " + "The single real DIALOGUE_MAIN runs tomorrow in the limited batch and is " + "counted against the shared authoritative guard ledger (6-turn cap).") + print(json.dumps(info, ensure_ascii=False, indent=1)) + (db_path.parent / "seed-info.json").write_text( + json.dumps(info, ensure_ascii=False, indent=1), encoding="utf-8") + + +if __name__ == "__main__": + main()