chore(release): prepare 0.4.1 (#6570)
Prepare version 0.4.1 and document the retained legacy upgrade path. Avoid false busy update handoffs from disabled or not-yet-due idle scans. Keep real work, maintenance, lease and data-protection checks intact. Retain safe package-failure diagnostics and cancellable test-controller progress checks. Reduce Windows installer startup contention without changing command deadlines or behavioral assertions. Validated on the reviewed head with all required PR checks and the exact five-platform candidate. Historical package and recovery coverage remains as documented in the release acceptance record. Publication is separate; this merge does not create a tag, release, upload or feed change.
This commit is contained in:
1 parent
1a89a25abd
commit
cdaae66c89
15 files changed
+310
-37
No files matched your search
@@ -1479,12 +1479,14 @@ async def test_stop_during_committed_goal_checkpoint_settles_queued_command(
|
||||
session.metadata[GOAL_STATE_KEY] = {"status": "active", "objective": "Finish the goal."}
|
||||
loop.sessions.save(session)
|
||||
calls = 0
|
||||
model_progress: asyncio.Queue[int] = asyncio.Queue()
|
||||
|
||||
async def respond(*args, **kwargs):
|
||||
nonlocal calls
|
||||
if args and "You write short, neutral chat titles" in str(args[0]):
|
||||
return LLMResponse(content="Goal checkpoint")
|
||||
calls += 1
|
||||
model_progress.put_nowait(calls)
|
||||
if calls == 3:
|
||||
await loop._dispatch_inbound(InboundMessage(
|
||||
channel="websocket", sender_id="user", chat_id="committed-checkpoint",
|
||||
@@ -1505,12 +1507,15 @@ async def test_stop_during_committed_goal_checkpoint_settles_queued_command(
|
||||
loop.provider.chat_stream_with_retry = AsyncMock(side_effect=respond)
|
||||
loop.runner.run = AsyncMock(wraps=loop.runner.run)
|
||||
committed, release = threading.Event(), threading.Event()
|
||||
checkpoint_ready = asyncio.Event()
|
||||
event_loop = asyncio.get_running_loop()
|
||||
publish = loop.sessions.state._publish
|
||||
|
||||
def hold_after_commit(saved, *args, **kwargs):
|
||||
checkpoint = saved.metadata.get(RUNTIME_CHECKPOINT_KEY, {})
|
||||
if checkpoint.get("phase") == "tools_completed" and calls == 3 and not committed.is_set():
|
||||
committed.set()
|
||||
event_loop.call_soon_threadsafe(checkpoint_ready.set)
|
||||
if not release.wait(5):
|
||||
raise TimeoutError("test did not release the committed save")
|
||||
return publish(saved, *args, **kwargs)
|
||||
@@ -1536,7 +1541,12 @@ async def test_stop_during_committed_goal_checkpoint_settles_queued_command(
|
||||
bus_task = asyncio.create_task(loop.run())
|
||||
try:
|
||||
await loop.bus.publish_inbound(msg)
|
||||
assert await asyncio.wait_for(asyncio.to_thread(committed.wait), 5)
|
||||
# Establish each preparation step before measuring Stop responsiveness.
|
||||
# An async observer also cancels without leaving an executor thread waiting.
|
||||
for expected_call in (1, 2, 3):
|
||||
assert await asyncio.wait_for(model_progress.get(), 5) == expected_call
|
||||
await asyncio.wait_for(checkpoint_ready.wait(), 5)
|
||||
assert committed.is_set()
|
||||
worker, = loop._active_tasks[msg.session_key]
|
||||
assert gate.locked()
|
||||
assert loop._pending_queues[msg.session_key].qsize() == 1
|
||||
|
||||
@@ -275,6 +275,7 @@ async def test_queued_event_dispatch_cannot_be_overtaken_by_maintenance(agent):
|
||||
|
||||
|
||||
async def test_async_idle_scan_keeps_storage_work_owned(agent, monkeypatch):
|
||||
agent.auto_compact._ttl = 15
|
||||
entered, release = asyncio.Event(), asyncio.Event()
|
||||
|
||||
async def scan(*args, **kwargs):
|
||||
@@ -297,7 +298,67 @@ async def test_async_idle_scan_keeps_storage_work_owned(agent, monkeypatch):
|
||||
assert agent.bus.admission.paused
|
||||
|
||||
|
||||
async def test_disabled_idle_scan_does_not_block_maintenance_on_storage(agent, monkeypatch):
|
||||
agent.auto_compact._ttl = 0
|
||||
reading, release = asyncio.Event(), asyncio.Event()
|
||||
|
||||
async def list_sessions():
|
||||
reading.set()
|
||||
await release.wait()
|
||||
return []
|
||||
|
||||
monkeypatch.setattr(agent.sessions.state, "list_sessions", list_sessions)
|
||||
scan = asyncio.create_task(agent._check_expired_sessions_if_due())
|
||||
try:
|
||||
await asyncio.sleep(0)
|
||||
with agent.maintenance():
|
||||
assert not reading.is_set()
|
||||
assert scan.done()
|
||||
finally:
|
||||
release.set()
|
||||
await scan
|
||||
|
||||
|
||||
@pytest.mark.parametrize("ttl,next_check", [(0, 0), (15, float("inf"))], ids=["disabled", "not-due"])
|
||||
async def test_idle_tick_without_due_work_keeps_maintenance_available(agent, monkeypatch, ttl, next_check):
|
||||
agent.auto_compact._ttl = ttl
|
||||
agent._next_idle_compact_check_at = next_check
|
||||
inspected, input_ready = asyncio.Event(), asyncio.Event()
|
||||
outcomes = []
|
||||
|
||||
def inspect_maintenance():
|
||||
try:
|
||||
with agent.maintenance():
|
||||
outcomes.append("idle")
|
||||
except RuntimeBusyError:
|
||||
outcomes.append("busy")
|
||||
finally:
|
||||
inspected.set()
|
||||
|
||||
first_tick = True
|
||||
|
||||
async def consume():
|
||||
nonlocal first_tick
|
||||
if first_tick:
|
||||
first_tick = False
|
||||
asyncio.get_running_loop().call_soon(inspect_maintenance)
|
||||
raise asyncio.TimeoutError
|
||||
await input_ready.wait()
|
||||
|
||||
monkeypatch.setattr(agent.bus, "consume_inbound", consume)
|
||||
consumer = asyncio.create_task(agent.run())
|
||||
try:
|
||||
async with asyncio.timeout(3):
|
||||
await inspected.wait()
|
||||
assert outcomes == ["idle"]
|
||||
finally:
|
||||
agent.stop()
|
||||
consumer.cancel()
|
||||
await asyncio.gather(consumer, return_exceptions=True)
|
||||
|
||||
|
||||
async def test_idle_storage_scan_does_not_delay_stop(agent, monkeypatch):
|
||||
agent.auto_compact._ttl = 15
|
||||
model_started, scan_started, release_scan = (asyncio.Event() for _ in range(3))
|
||||
original_list = agent.sessions.state.list_sessions
|
||||
|
||||
@@ -336,6 +397,7 @@ async def test_idle_storage_scan_does_not_delay_stop(agent, monkeypatch):
|
||||
|
||||
|
||||
async def test_idle_tick_during_maintenance_does_not_start_scan(agent, monkeypatch):
|
||||
agent.auto_compact._ttl = 15
|
||||
async def idle_once():
|
||||
agent.stop()
|
||||
raise asyncio.TimeoutError
|
||||
@@ -351,6 +413,7 @@ async def test_idle_tick_during_maintenance_does_not_start_scan(agent, monkeypat
|
||||
|
||||
@pytest.mark.parametrize("scan_fails", [False, True])
|
||||
async def test_idle_scan_is_single_flight_and_drains_spawned_work(agent, monkeypatch, scan_fails):
|
||||
agent.auto_compact._ttl = 15
|
||||
entered, release, child_started, release_child = (asyncio.Event() for _ in range(4))
|
||||
|
||||
async def child():
|
||||
|
||||
@@ -124,6 +124,7 @@ async def test_rejected_input_does_not_stop_other_sessions(loop, monkeypatch, re
|
||||
|
||||
loop.provider.chat_stream_with_retry = chat
|
||||
if rejection == "idle":
|
||||
loop.auto_compact._ttl = 15
|
||||
original_check = loop.auto_compact.check_expired
|
||||
|
||||
async def observed_check(*args, **kwargs):
|
||||
|
||||
Reference in new issue
Block a user