fix(history): preserve chronological replay ownership

This commit is contained in:
冰朔 2026-08-01 18:52:28 +08:00
commit efec80bc0e
2 changed files with 18 additions and 0 deletions

View file

@ -30,6 +30,11 @@ PERSONAS = {
PRIVATE_MARKERS = ("email", "token", "password", "secret", "api_key", "private_key")
STREAM_BUFFER_BYTES = 1024 * 1024
GPT_METADATA_SAMPLE_BYTES = 128 * 1024
SOURCE_WAITING_STATUSES = {
"PENDING",
"WAITING_FOR_SOURCE",
"WAITING_FOR_SOURCE_ACCEPTANCE",
}
def now_iso() -> str:
@ -62,6 +67,11 @@ def classify_personas(text: str) -> list[str]:
]
def blocks_later_history(status: str) -> bool:
"""An available active/error source owns the chronological replay lane."""
return status != "COMPLETE" and status not in SOURCE_WAITING_STATUSES
def iter_top_level_json_objects(
handle: BinaryIO, start_offset: int = 0
) -> Iterator[tuple[bytes, int]]:
@ -753,6 +763,8 @@ class Runtime:
self.process_source(source)
if self.stop.is_set():
break
if blocks_later_history(self.store.state(source["id"])["status"]):
break
return self.write_public()
def run(self) -> None: