Clear the SSE event log on every worker start, including Retry failed.
Resume reused the previous pipeline_complete, so the UI closed the stream and showed no live log while U19 was still reviewing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -81,11 +81,13 @@ async def _run() -> None:
|
|||||||
# are visible to any API instance tailing the event log.
|
# are visible to any API instance tailing the event log.
|
||||||
pipeline_svc.set_broker(event_bridge.GCSEventBroker(storage, user_id))
|
pipeline_svc.set_broker(event_bridge.GCSEventBroker(storage, user_id))
|
||||||
|
|
||||||
# Fresh runs wipe the prior event log so the SSE consumer doesn't
|
# Always wipe the prior event log. Reprocess uses resume=True, and
|
||||||
# mix old events into the new run. Resume keeps the prior log so
|
# the old log still contains ``pipeline_complete``; the SSE tail
|
||||||
# users see the full history.
|
# would stop there and the UI would show a finished run with no live
|
||||||
if not resume:
|
# log while the worker is still reviewing. Pause-resume also hits a
|
||||||
pipeline_svc.broker.clear_history(project_id)
|
# terminal ``pipeline_paused``. A fresh seq from 0 is the only safe
|
||||||
|
# option — completed_review_refs still skip paid ICs.
|
||||||
|
pipeline_svc.broker.clear_history(project_id)
|
||||||
|
|
||||||
if mode == "run":
|
if mode == "run":
|
||||||
await pipeline_svc.run_pipeline(
|
await pipeline_svc.run_pipeline(
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
"""GCS event log: a new run must not replay a prior pipeline_complete."""
|
||||||
|
|
||||||
|
from backend.services.event_bridge import GCSEventBroker
|
||||||
|
|
||||||
|
|
||||||
|
def test_clear_history_wipes_terminal_events(tmp_path):
|
||||||
|
from backend.services.storage import LocalStorageBackend
|
||||||
|
|
||||||
|
storage = LocalStorageBackend(tmp_path)
|
||||||
|
broker = GCSEventBroker(storage, "local")
|
||||||
|
broker.publish("p1", "step_update", {"stage": "validation"})
|
||||||
|
broker.publish("p1", "pipeline_complete", {"summary": {}})
|
||||||
|
|
||||||
|
prefix = "users/local/projects/p1/events/"
|
||||||
|
assert len(storage.list_prefix(prefix)) == 2
|
||||||
|
|
||||||
|
broker.clear_history("p1")
|
||||||
|
assert storage.list_prefix(prefix) == []
|
||||||
|
|
||||||
|
broker.publish("p1", "step_update", {"stage": "bom_parse"})
|
||||||
|
keys = storage.list_prefix(prefix)
|
||||||
|
assert len(keys) == 1
|
||||||
|
assert keys[0].endswith("0000000000.json")
|
||||||
|
assert storage.read_json(keys[0])["event"] == "step_update"
|
||||||
Reference in New Issue
Block a user