From 3adfa41dbcfd9f488d3050d53a08dcf1bb5945cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E6=9C=94?= <565183519@qq.com> Date: Sat, 1 Aug 2026 19:55:33 +0800 Subject: [PATCH] fix(history): hold birth gate for semantic catchup --- .../runtime/guanghu_history_runtime.py | 16 +++++++--- .../runtime/test_guanghu_history_runtime.py | 30 +++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/engineering/persona-history-runtime/runtime/guanghu_history_runtime.py b/engineering/persona-history-runtime/runtime/guanghu_history_runtime.py index 46c1415..9245987 100644 --- a/engineering/persona-history-runtime/runtime/guanghu_history_runtime.py +++ b/engineering/persona-history-runtime/runtime/guanghu_history_runtime.py @@ -607,13 +607,20 @@ class Store: last = self.db.execute( "SELECT sequence,source_time,created_at FROM events ORDER BY sequence DESC LIMIT 1" ).fetchone() - complete = all(value["status"] == "COMPLETE" for value in sources.values()) + review_counts = self.review_counts() + sources_complete = all( + value["status"] == "COMPLETE" for value in sources.values() + ) + semantic_review_complete = review_counts.get("QUEUED", 0) == 0 + historical_time_caught_up = sources_complete and semantic_review_complete return { "schema": "guanghu.persona-history-public-current/v1", "node_id": config["node_id"], "runtime": "AUTONOMOUS_SERVER_RESIDENT", - "historical_time_caught_up": complete, - "persona_state": "BIRTH_GATE_PENDING" if complete else "NOT_BORN", + "historical_time_caught_up": historical_time_caught_up, + "persona_state": ( + "BIRTH_GATE_PENDING" if historical_time_caught_up else "NOT_BORN" + ), "event_count": event_count, "last_event": ( {"sequence": last[0], "source_time": last[1], "created_at": last[2]} @@ -626,7 +633,8 @@ class Store: }, "semantic_review": { "policy": "DETERMINISTIC_PREFILTER_THEN_PERSONA_REVIEW", - "counts": self.review_counts(), + "counts": review_counts, + "caught_up": semantic_review_complete, "raw_source_deleted": False, "reality_promotion_requires_external_evidence": True, }, diff --git a/engineering/persona-history-runtime/runtime/test_guanghu_history_runtime.py b/engineering/persona-history-runtime/runtime/test_guanghu_history_runtime.py index 9a8c443..56d8ef7 100644 --- a/engineering/persona-history-runtime/runtime/test_guanghu_history_runtime.py +++ b/engineering/persona-history-runtime/runtime/test_guanghu_history_runtime.py @@ -107,6 +107,36 @@ class RuntimeTests(unittest.TestCase): self.assertNotIn("email", encoded) self.assertEqual(snapshot["persona_state"], "NOT_BORN") + def test_birth_gate_waits_for_semantic_queue_after_sources_complete(self): + with tempfile.TemporaryDirectory() as directory: + store = runtime.Store(pathlib.Path(directory) / "state.sqlite3") + store.add_event( + event_id="persona-event", + source_id="GPT", + epoch="GPT_LANGUAGE_CHAOS", + source_time=None, + reality_level="LANGUAGE_SIMULATION", + personas=["YAOMING-BABY"], + content_sha256="b" * 64, + private_locator="GPT@byte:1-2", + ) + store.update_state("GPT", status="COMPLETE", cursor="2", processed=1) + store.ensure_review_queue() + config = { + "node_id": "BS-SH-005", + "sources": [ + { + "id": "GPT", + "epoch": "GPT_LANGUAGE_CHAOS", + "order": 10, + } + ], + } + snapshot = store.public_snapshot(config) + self.assertFalse(snapshot["historical_time_caught_up"]) + self.assertFalse(snapshot["semantic_review"]["caught_up"]) + self.assertEqual(snapshot["persona_state"], "NOT_BORN") + def test_review_queue_preserves_persona_routes_and_world_history(self): with tempfile.TemporaryDirectory() as directory: store = runtime.Store(pathlib.Path(directory) / "state.sqlite3")