Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566"""A cursor from a daemon that crashed resets onto durable history.
Replay within one actor, a replaced actor's cursor, an evicted cursor and areset that cannot read history are checked in process byapps/albedo/test/albedo/session/stream_replay_test.gleam. Only a real daemonrestart shows the generation changing across processes. `restart_actor` staysfor tool_progress_test.py."""
import jsonimport unittest
from inspect_support import Inspectionfrom harness import Albedo, Provider, ROOT, exclusive, text
def restart_actor(app, session): inspection = Inspection(app, ROOT / "e2e/albedo_stream_replay_probe.erl") result = inspection.call("restart", f"[<<{json.dumps(session)}>>]") if result != "actor_stopped": raise AssertionError(result)
class StreamReplayTest(unittest.TestCase): def setUp(self): self.provider = Provider(lambda _: text("answer")) self.addCleanup(self.provider.close)
def turn(self, app, session, prompt): app.prompt(session, prompt).close() app.idle(session)
def assert_reset_history(self, page, prompts): self.assertEqual(page["events"][0]["type"], "reset") self.assertEqual( [ part["text"] for entry in page["snapshot"]["history"]["items"] if entry["kind"] == "user" for part in entry["content"] if part["kind"] == "text" ], prompts, )
# exclusive: restarts the daemon @exclusive def test_old_daemon_cursor_resets_durable_history(self): with Albedo(self.provider) as app: session = app.session() self.turn(app, session, "before daemon restart") old = app.stream_page(session) app.restart(crash=True) self.turn(app, session, "after daemon restart") current = app.stream_page(session) replay = app.stream_page(session, old) self.assert_reset_history( replay, ["before daemon restart", "after daemon restart"] ) self.assertNotEqual(replay["generation"], old["generation"]) self.assertEqual(replay["generation"], current["generation"])
if __name__ == "__main__": unittest.main()