Live Stream: preserve Worklog identity across active session reattach#6304
Live Stream: preserve Worklog identity across active session reattach#6304franksong2702 wants to merge 5 commits into
Conversation
|
| Filename | Overview |
|---|---|
| api/routes.py | Refactors run-journal snapshot to track per-segment reasoning (not one aggregate), adds segment high-water, journal-order sort for chronological row ordering, and strips internal fields from the public response. Logic is correct and thoroughly tested. |
| static/messages.js | Key browser-side fixes: empty live-reasoning buffer on reattach, seal-segment-before-tool helper, session-switch anchor persistence in the done handler, authoritative-thinking preference over transcript aggregate in settlement. All paths guarded correctly. |
| tests/browser_conversation_lifecycle.py | Adds session-reattach scenario with sidebar switch, inflight/registry cache clearing, runtime-scene wait, semantic identity assertions, continuation reasoning check, and terminal navigation ownership window. |
| .github/workflows/conversation-lifecycle.yml | Adds reattach step with if: always() guard so it executes even when the normal gate fails; job-level continue-on-error: true keeps the workflow informational. |
| tests/test_anchor_scene_persistence.py | Adds tests for multi-segment reasoning identities, completion-only tool boundary, no-prose global order, timestamp preservation, hydration preference for persisted segments, and cross-segment echo stripping. |
| tests/test_live_to_final_anchor_visible_order.py | Adds structural tests for the session-switch done handler path, duplicate-thinking suppression, and final-suffix live-accumulator deduplication. |
Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'origin/mas..." | Re-trigger Greptile
| base_url: str, | ||
| session_id: str, | ||
| expected_reasoning_ids: list[str], | ||
| timeout: float = 10.0, |
There was a problem hiding this comment.
Hard-coded 10 s timeout is inconsistent with established CI constant
_wait_for_runtime_scene polls until the server's runtime journal scene exposes the expected reasoning IDs. The rest of this file uses ANCHOR_SCENE_PERSIST_TIMEOUT = 60.0 for analogous waits; the new function uses a hardcoded 10.0. On a loaded CI runner the journal rebuild can be delayed, causing a false-negative assertion failure where the established constant would have waited long enough.
| timeout: float = 10.0, | |
| timeout: float = ANCHOR_SCENE_PERSIST_TIMEOUT, |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
943cfef to
f89f7af
Compare
|
Aftercare readback at
|
Closes #6303
Thinking Path
and owner across live rendering, settlement, and reload.
switch/reattach as a separate proof-matrix row.
INFLIGHTor Anchor registries; the durable run journal mustreconstruct the same scene and cursor.
between the live browser path and server replay, especially around no-prose tools and reasoning
echoes.
switch, post-return continuation, settlement, and hard reload.
donecould retain the complete stream-owned Anchorregistry but skip persistence when
_loadingSessionIdalready pointed at another session.What Changed
session-reattachlifecycle workflow scenario built on Live Stream: add public conversation lifecycle browser gate #6251's realserver/Gateway/Chromium seam.
the sidebar, and clear browser-only inflight/Anchor caches before returning so durable recovery is
required.
post-reattach reasoning continuation, settlement, and hard-reload parity.
preserve journal chronology for no-prose and completion-only tools, including after reasoning echo
removal.
for events received after reattach.
and drop stale live Thinking rows when their content no longer matches the settled transcript.
mutating the destination pane, using the completed payload's own message offset.
done, then return andprove settled/hard-reload parity; collect ownership/registry diagnostics on failure.
results in the informational job.
TESTING.md.Why It Matters
Users should be able to inspect another session and return to an active run without changing what the
assistant has already shown. The same reasoning, process prose, and tool activity should remain in the
same order, and new activity should append once to the same assistant turn.
This also turns that product invariant into a public browser gate, so future streaming/replay changes
can be checked without real credentials or private user sessions.
Behavioral Before / After
Before the fix, red regressions showed:
[thinking, prose, tool, thinking]after replay for a live chronology of[thinking, tool, prose, thinking];[1, 1, 2, 1, 3]where the live browser owned[1, 1, 2, 2, 3];donelandedafter navigation started, so returning showed final prose but no Worklog.
After the fix, the browser gate preserves the same semantic scene before switch, after reattach,
after new reasoning, through a terminal navigation window, after settlement, and after hard reload.
There are no CSS, layout, or control changes. Semantic browser snapshots and identity/order
assertions are the relevant visual-behavior proof; static screenshots cannot prove row ownership.
Contract Routing
Task type: runtime/replay correctness fix plus contract-semantic regression coverage.
Touched areas:
api/routes.py)static/messages.js)Relevant public docs:
AGENTS.mdCONTRIBUTING.mddocs/CONTRACTS.mddocs/rfcs/live-to-final-assistant-replies.mddocs/rfcs/stable-assistant-turn-anchors.mddocs/rfcs/webui-run-state-consistency-contract.mddocs/rfcs/session-sse-contract-v1.mdState ownership:
/api/sessionsnapshot own durable reattach data;INFLIGHTand the Anchor registry own browser live projection only;destination session's visible pane;
activity_scene_v1owns settled/reload presentation;Contract effect: no intentional contract change. This PR enforces the existing one-turn, one-ordered-
activity-model invariant across an additional lifecycle transition.
Verification
Red-before-green evidence:
[thinking, prose, tool, thinking]instead of[thinking, tool, prose, thinking];[1, 1, 2, 1, 3]instead of[1, 1, 2, 2, 3];Final verification after base-refresh head
bf718ee50:bf718ee50: browser-smoke, docs-ci, lint, informationallive-to-final, Greptile, and all Python 3.11/3.12/3.13 test shards pass./scripts/test.sh tests/test_anchor_scene_persistence.py tests/test_run_journal_routes.py tests/test_live_anchor_progress_echo.py tests/test_pure_prose_turn_not_worklog.py::test_gates_call_worklog_worthy_predicate tests/test_stable_assistant_turn_anchor_registry.py::test_slice6_live_shadow_feed_wires_anchor_scene_for_visible_order_handoff tests/test_issue3820_chat_activity_display_mode.py::test_chat_activity_display_mode_settled_hide_all_scene_persists_without_worklog tests/test_5749_anchor_scene_client_prefix_dedupe.py::test_settled_scene_keys_live_token_prefix_dedupe_to_final_answer_identity tests/test_live_to_final_anchor_visible_order.py::test_done_persists_owned_anchor_scene_during_session_switch_window tests/test_live_to_final_anchor_visible_order.py::test_settled_anchor_scene_suppresses_final_suffix_live_accumulator tests/test_regressions.py::test_messages_js_supports_live_reasoning_and_tool_completion -q->74 passedLIFECYCLE_ARTIFACT_DIR=/tmp/hermes-pr6304-lifecycle-session-reattach-refresh LIFECYCLE_SCENARIO=session-reattach .venv/bin/python tests/browser_conversation_lifecycle.py-> passgit diff --check origin/master...HEAD.venv/bin/ruff check --diff origin/master-> no new violations333 passed, 1 skipped(the skip requires a localhermes-agentexecutable)10/10LIFECYCLE_TEST_BITE=drop-anchor-persistence-> expected nonzero failure after live + settledLIFECYCLE_SCENARIO=session-reattach LIFECYCLE_TEST_BITE=replace-runtime-reasoning-id->expected nonzero identity failure after switching back
all latest-head checks pass and the refreshed Greptile review reports no blocker
Risks / Follow-ups
browser seam rather than replacing it.
out of scope.
claim provider-specific event behavior.
Release Note
Active sessions now preserve the same ordered Compact Worklog when users switch to another session
and return, including new reasoning that arrives after reattach, terminal completion during the
navigation window, and parity after settlement/reload.
Model Used
testing, and an independent Codex sub-agent review