harness-sdk-python 0.40.11__tar.gz → 0.40.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/PKG-INFO +3 -3
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/pyproject.toml +2 -2
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/run_manager.py +53 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/run_helpers.py +4 -0
- harness_sdk_python-0.40.12/tests/test_stale_redelivery.py +183 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/.gitignore +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/README.md +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/examples/__init__.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/examples/local_origin.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/examples/runs_app.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/__init__.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/checkpoints.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/deepagents.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/deepagents_host.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/fenced_postgres.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/interest.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/langgraph.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/linear_thread.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/messages.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/parts.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/prioritize.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/protocol.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/providers/__init__.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/providers/gpt_live.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/threads.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/voice.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/voice_thread.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/wire.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_admit_steer.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_applied_visibility.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_batches.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_branch_anchor.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_checkpoints.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_deepagents_approval.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_deepagents_files.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_deepagents_multi_approval.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_deepagents_outcome.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_deepagents_subagent_approval.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_deepagents_thread.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_deepagents_user_ids.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_deepagents_voice.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_dispatching.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_durability.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_edit_dispatched.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_edit_reload.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_enqueue.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_example_local_origin.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_fenced_postgres.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_gpt_live.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_imports.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_input_required.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_interest.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_langgraph.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_linear_thread.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_meta.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_mint_concurrency.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_outcomes.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_parts.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_placement.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_prepare_hooks.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_prioritize.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_prioritize_builtins.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_request_options.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_restore.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_rewind_during_run.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_run_admission.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_run_crash_sweep.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_run_eviction.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_run_id_bounds.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_run_ownership.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_run_sync.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_settle.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_steer.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_stop_continue.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_stopping_window.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_threads.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_undo.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_voice.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_voice_delegation.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_voice_events.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_wire.py +0 -0
- {harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/voice_helpers.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: harness-sdk-python
|
|
3
|
-
Version: 0.40.
|
|
3
|
+
Version: 0.40.12
|
|
4
4
|
Summary: RunManager: the harness-sdk runs subsystem for Python Statewire hosts
|
|
5
5
|
Project-URL: Repository, https://github.com/assistant-ui/harness-sdk
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Requires-Python: <4.0,>=3.12
|
|
8
|
-
Requires-Dist: pinboard-sdk>=0.18.
|
|
9
|
-
Requires-Dist: statewire<0.25,>=0.24.
|
|
8
|
+
Requires-Dist: pinboard-sdk>=0.18.4
|
|
9
|
+
Requires-Dist: statewire<0.25,>=0.24.3
|
|
10
10
|
Provides-Extra: deepagents
|
|
11
11
|
Requires-Dist: deepagents>=0.6.12; extra == 'deepagents'
|
|
12
12
|
Requires-Dist: langchain-core>=0.3; extra == 'deepagents'
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "harness-sdk-python"
|
|
3
|
-
version = "0.40.
|
|
3
|
+
version = "0.40.12"
|
|
4
4
|
description = "RunManager: the harness-sdk runs subsystem for Python Statewire hosts"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
7
7
|
requires-python = ">=3.12,<4.0"
|
|
8
|
-
dependencies = ["statewire>=0.24.
|
|
8
|
+
dependencies = ["statewire>=0.24.3,<0.25", "pinboard-sdk>=0.18.4"]
|
|
9
9
|
|
|
10
10
|
[project.optional-dependencies]
|
|
11
11
|
postgres = ["langgraph-checkpoint-postgres>=2.0.0"]
|
|
@@ -65,6 +65,7 @@ projections.
|
|
|
65
65
|
import asyncio
|
|
66
66
|
import inspect
|
|
67
67
|
import logging
|
|
68
|
+
import math
|
|
68
69
|
from dataclasses import dataclass, field
|
|
69
70
|
from typing import (
|
|
70
71
|
Any,
|
|
@@ -432,6 +433,7 @@ class RunManager(Tray):
|
|
|
432
433
|
|
|
433
434
|
capabilities: frozenset[str] = frozenset()
|
|
434
435
|
max_queued: int = 50
|
|
436
|
+
max_redelivery_age: float | None = None
|
|
435
437
|
prepare_message: Callable[[dict[str, Any]], dict[str, Any]] | None = None
|
|
436
438
|
prepare_input: Callable[[dict[str, Any]], dict[str, Any]] | None = None
|
|
437
439
|
prioritize: "Callable[[RunManager.PrioritizeRequest], Awaitable[str] | str] | None" = None
|
|
@@ -491,6 +493,7 @@ class RunManager(Tray):
|
|
|
491
493
|
self._input_answers: dict[str, Any] = {}
|
|
492
494
|
self._run_live: "RunManager.RunContext | None" = None
|
|
493
495
|
self._fresh = False
|
|
496
|
+
self._redelivering = False
|
|
494
497
|
self._closing = False
|
|
495
498
|
self._idle = asyncio.Event()
|
|
496
499
|
self._verdict_waiters: dict[str, "asyncio.Future[dict[str, Any]]"] = {}
|
|
@@ -1094,9 +1097,11 @@ class RunManager(Tray):
|
|
|
1094
1097
|
item = recorded["item"]
|
|
1095
1098
|
if self._fresh:
|
|
1096
1099
|
self._fresh = False
|
|
1100
|
+
self._redelivering = False
|
|
1097
1101
|
else:
|
|
1098
1102
|
self.outbox.dispatch(item) # redelivery bumps the attempt
|
|
1099
1103
|
self._reclaim(item)
|
|
1104
|
+
self._redelivering = True
|
|
1100
1105
|
yield item
|
|
1101
1106
|
|
|
1102
1107
|
def _reclaim(self, item: Any) -> None:
|
|
@@ -1144,7 +1149,46 @@ class RunManager(Tray):
|
|
|
1144
1149
|
ctx.stop_requested.set()
|
|
1145
1150
|
return ctx
|
|
1146
1151
|
|
|
1152
|
+
async def _stale_reason(self, item: Any, resume: bool) -> str | None:
|
|
1153
|
+
max_age = self.max_redelivery_age
|
|
1154
|
+
since = self._ledger.since
|
|
1155
|
+
if max_age is not None and since is not None:
|
|
1156
|
+
# pinboard's first-delivery time; a row from before it is stamped
|
|
1157
|
+
# at this redelivery, so its window starts at the upgrade
|
|
1158
|
+
age = self._domain.now() - since
|
|
1159
|
+
if age > max_age:
|
|
1160
|
+
return f"it was first dispatched {age / 3600:.1f}h ago"
|
|
1161
|
+
thread = self.handler.__self__
|
|
1162
|
+
record = item["record"]
|
|
1163
|
+
probes = [
|
|
1164
|
+
message["id"] if resume else message.get("~parent", _ABSENT)
|
|
1165
|
+
for message in record["messages"]
|
|
1166
|
+
]
|
|
1167
|
+
if not resume:
|
|
1168
|
+
# an unapplied edit or reload records its rewound parent here
|
|
1169
|
+
probes.append(record.get("rollbackTo", _ABSENT))
|
|
1170
|
+
for probe in probes:
|
|
1171
|
+
if probe is _ABSENT or (probe is None and not resume):
|
|
1172
|
+
continue
|
|
1173
|
+
meta = await thread.get_message_meta(probe)
|
|
1174
|
+
if meta is not None and meta.get("onActiveBranch") is False:
|
|
1175
|
+
return f"message {probe!r} is no longer on the active branch"
|
|
1176
|
+
return None
|
|
1177
|
+
|
|
1178
|
+
def _guard_redelivery(self, item: Any, fn: Callable[..., Any]) -> Callable[..., Any]:
|
|
1179
|
+
async def guarded(ctx: "RunManager.RunContext") -> Any:
|
|
1180
|
+
reason = await self._stale_reason(item, ctx.resume)
|
|
1181
|
+
if reason is not None:
|
|
1182
|
+
logger.warning("run %r refused its redelivery: %s", self.id, reason)
|
|
1183
|
+
raise _reject("stale-redelivery", f"run not resumed: {reason}")
|
|
1184
|
+
return await fn(ctx)
|
|
1185
|
+
|
|
1186
|
+
return guarded
|
|
1187
|
+
|
|
1147
1188
|
async def _run_item(self, item: Any, fn: Callable[..., Any]) -> Any:
|
|
1189
|
+
if self._redelivering:
|
|
1190
|
+
self._redelivering = False
|
|
1191
|
+
fn = self._guard_redelivery(item, fn)
|
|
1148
1192
|
ctx = self._make_run_ctx(item)
|
|
1149
1193
|
self._run_live = ctx
|
|
1150
1194
|
task = asyncio.ensure_future(self._execute(ctx, fn))
|
|
@@ -2744,6 +2788,7 @@ def run_manager(
|
|
|
2744
2788
|
*,
|
|
2745
2789
|
capabilities: Iterable[str] = (),
|
|
2746
2790
|
max_queued: int = 50,
|
|
2791
|
+
max_redelivery_age: float | None = None,
|
|
2747
2792
|
prepare_message: Callable[[dict[str, Any]], dict[str, Any]] | None = None,
|
|
2748
2793
|
prepare_input: Callable[[dict[str, Any]], dict[str, Any]] | None = None,
|
|
2749
2794
|
prioritize: "Callable[[RunManager.PrioritizeRequest], Awaitable[str] | str] | None" = None,
|
|
@@ -2759,6 +2804,13 @@ def run_manager(
|
|
|
2759
2804
|
raise ValueError("rewind-during-run requires the rewind capability")
|
|
2760
2805
|
if max_queued < 1:
|
|
2761
2806
|
raise ValueError("max_queued must be >= 1")
|
|
2807
|
+
if max_redelivery_age is not None and (
|
|
2808
|
+
isinstance(max_redelivery_age, bool)
|
|
2809
|
+
or not isinstance(max_redelivery_age, (int, float))
|
|
2810
|
+
or not math.isfinite(max_redelivery_age)
|
|
2811
|
+
or max_redelivery_age <= 0
|
|
2812
|
+
):
|
|
2813
|
+
raise ValueError("max_redelivery_age must be a positive number of seconds or None")
|
|
2762
2814
|
if prioritize is not None and not callable(prioritize):
|
|
2763
2815
|
raise TypeError("prioritize must be callable")
|
|
2764
2816
|
|
|
@@ -2769,6 +2821,7 @@ def run_manager(
|
|
|
2769
2821
|
{
|
|
2770
2822
|
"capabilities": caps,
|
|
2771
2823
|
"max_queued": max_queued,
|
|
2824
|
+
"max_redelivery_age": max_redelivery_age,
|
|
2772
2825
|
"prepare_message": staticmethod(prepare_message)
|
|
2773
2826
|
if prepare_message is not None
|
|
2774
2827
|
else None,
|
|
@@ -74,6 +74,7 @@ def make_host(
|
|
|
74
74
|
authorize=None,
|
|
75
75
|
version=HARNESS_PROTOCOL.version,
|
|
76
76
|
prioritize=None,
|
|
77
|
+
max_redelivery_age=None,
|
|
77
78
|
):
|
|
78
79
|
class Host(Statewire):
|
|
79
80
|
protocols = (
|
|
@@ -97,6 +98,7 @@ def make_host(
|
|
|
97
98
|
@run_manager(
|
|
98
99
|
capabilities=capabilities,
|
|
99
100
|
max_queued=max_queued,
|
|
101
|
+
max_redelivery_age=max_redelivery_age,
|
|
100
102
|
prepare_message=prepare_message,
|
|
101
103
|
prepare_input=prepare_input,
|
|
102
104
|
prioritize=prioritize,
|
|
@@ -334,6 +336,7 @@ async def run_host(
|
|
|
334
336
|
version=HARNESS_PROTOCOL.version,
|
|
335
337
|
prioritize=None,
|
|
336
338
|
client_id=None,
|
|
339
|
+
max_redelivery_age=None,
|
|
337
340
|
):
|
|
338
341
|
"""``version`` is the negotiated protocol date the host passes to sends; None passes none."""
|
|
339
342
|
host_cls = make_host(
|
|
@@ -345,6 +348,7 @@ async def run_host(
|
|
|
345
348
|
authorize=authorize,
|
|
346
349
|
version=version,
|
|
347
350
|
prioritize=prioritize,
|
|
351
|
+
max_redelivery_age=max_redelivery_age,
|
|
348
352
|
)
|
|
349
353
|
worker = Worker(
|
|
350
354
|
state_store=store if store is not None else MemoryStateStore()
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"""Contract: a run interrupted mid-flight redelivers on a later activation only
|
|
2
|
+
while its messages stay on the active branch and, with ``max_redelivery_age``
|
|
3
|
+
set, while it is fresh by pinboard's first-delivery time (``~since``). A
|
|
4
|
+
refused redelivery settles as a ``stale-redelivery`` error without running:
|
|
5
|
+
the outbox acks, the row unmarks, and no later activation runs it again.
|
|
6
|
+
Without ``max_redelivery_age`` only pinboard's 14-day ceiling bounds age."""
|
|
7
|
+
|
|
8
|
+
import asyncio
|
|
9
|
+
|
|
10
|
+
from pinboard.testing import MemoryStateStore
|
|
11
|
+
from run_helpers import Script, add, edit_params, msg, reload_params, run_host
|
|
12
|
+
|
|
13
|
+
DAY = 24 * 3600.0
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def survivors(store: MemoryStateStore) -> MemoryStateStore:
|
|
17
|
+
crashed = MemoryStateStore()
|
|
18
|
+
crashed.trays = dict(store.trays)
|
|
19
|
+
return crashed
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def run_rows(store: MemoryStateStore) -> list[tuple[bool, dict]]:
|
|
23
|
+
return [row for key, row in store.trays.items() if key[2] == "runs"]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def rewrite_since(store: MemoryStateStore, change) -> None:
|
|
27
|
+
for key, (marked, doc) in list(store.trays.items()):
|
|
28
|
+
if key[2] == "runs" and doc.get("outbox") is not None:
|
|
29
|
+
doc = dict(doc)
|
|
30
|
+
since = change(doc.get("~since"))
|
|
31
|
+
if since is None:
|
|
32
|
+
doc.pop("~since", None)
|
|
33
|
+
else:
|
|
34
|
+
doc["~since"] = since
|
|
35
|
+
store.trays[key] = (marked, doc)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def run_since(store: MemoryStateStore) -> list:
|
|
39
|
+
return [doc.get("~since") for _m, doc in run_rows(store) if doc.get("outbox")]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
async def interrupted_run(script: Script, *, applied: bool = False) -> MemoryStateStore:
|
|
43
|
+
"""The store as a crash left it: m1's run in flight, never settled."""
|
|
44
|
+
store = MemoryStateStore()
|
|
45
|
+
async with run_host(script, store=store) as (drv, host):
|
|
46
|
+
drv.post("run/send", add("m1", behavior="queue"))
|
|
47
|
+
call = await script.next_call()
|
|
48
|
+
if applied:
|
|
49
|
+
call.applied()
|
|
50
|
+
await host.live.frontier.wait()
|
|
51
|
+
return survivors(store)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
async def assert_refused(store: MemoryStateStore, script: Script, **host) -> None:
|
|
55
|
+
async with run_host(script, store=store, **host) as (drv, _):
|
|
56
|
+
await drv.wait_status("error")
|
|
57
|
+
assert drv.run["error"]["reason"] == "stale-redelivery"
|
|
58
|
+
script.no_call()
|
|
59
|
+
assert [(marked, doc.get("outbox")) for marked, doc in run_rows(store)] == [
|
|
60
|
+
(False, None)
|
|
61
|
+
]
|
|
62
|
+
again = Script()
|
|
63
|
+
async with run_host(again, store=store, **host) as (drv, _):
|
|
64
|
+
await asyncio.sleep(0.05)
|
|
65
|
+
again.no_call()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
async def test_a_redelivery_past_max_age_settles_as_an_error_without_running():
|
|
69
|
+
crashed = await interrupted_run(Script())
|
|
70
|
+
rewrite_since(crashed, lambda since: since - 2 * DAY)
|
|
71
|
+
await assert_refused(crashed, Script(), max_redelivery_age=DAY)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
async def test_a_legacy_dispatch_without_a_time_is_stamped_and_redelivers():
|
|
75
|
+
crashed = await interrupted_run(Script())
|
|
76
|
+
rewrite_since(crashed, lambda since: None)
|
|
77
|
+
assert run_since(crashed) == [None]
|
|
78
|
+
script = Script()
|
|
79
|
+
async with run_host(script, store=crashed, max_redelivery_age=DAY) as (drv, _):
|
|
80
|
+
call = await script.next_call()
|
|
81
|
+
assert call.ctx.attempts == 2
|
|
82
|
+
assert all(isinstance(since, float) for since in run_since(crashed))
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
async def test_a_fresh_redelivery_still_runs():
|
|
86
|
+
crashed = await interrupted_run(Script())
|
|
87
|
+
rewrite_since(crashed, lambda since: since - 3600)
|
|
88
|
+
script = Script()
|
|
89
|
+
async with run_host(script, store=crashed, max_redelivery_age=DAY) as (drv, _):
|
|
90
|
+
call = await script.next_call()
|
|
91
|
+
assert call.ctx.attempts == 2
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
async def test_without_max_redelivery_age_a_week_old_run_redelivers():
|
|
95
|
+
crashed = await interrupted_run(Script())
|
|
96
|
+
rewrite_since(crashed, lambda since: since - 7 * DAY)
|
|
97
|
+
script = Script()
|
|
98
|
+
async with run_host(script, store=crashed):
|
|
99
|
+
await script.next_call()
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
async def test_an_applied_batch_off_the_active_branch_is_refused():
|
|
103
|
+
crashed = await interrupted_run(Script(), applied=True)
|
|
104
|
+
script = Script()
|
|
105
|
+
script.thread["m1"] = {
|
|
106
|
+
"parentId": None, "role": "user", "isLeaf": False, "onActiveBranch": False
|
|
107
|
+
}
|
|
108
|
+
await assert_refused(crashed, script)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
async def test_an_unapplied_batch_whose_parent_left_the_active_branch_is_refused():
|
|
112
|
+
script = Script()
|
|
113
|
+
script.thread["a0"] = {
|
|
114
|
+
"parentId": None, "role": "assistant", "isLeaf": True, "onActiveBranch": True
|
|
115
|
+
}
|
|
116
|
+
store = MemoryStateStore()
|
|
117
|
+
async with run_host(script, store=store) as (drv, host):
|
|
118
|
+
drv.post("run/send", add("m1", anchor="a0", behavior="queue"))
|
|
119
|
+
await script.next_call()
|
|
120
|
+
await host.live.frontier.wait()
|
|
121
|
+
crashed = survivors(store)
|
|
122
|
+
script2 = Script()
|
|
123
|
+
script2.thread["a0"] = {**script.thread["a0"], "onActiveBranch": False}
|
|
124
|
+
await assert_refused(crashed, script2)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
async def test_a_run_past_the_pinboard_ceiling_parks_without_running():
|
|
128
|
+
crashed = await interrupted_run(Script())
|
|
129
|
+
rewrite_since(crashed, lambda since: since - 15 * DAY)
|
|
130
|
+
script = Script()
|
|
131
|
+
async with run_host(script, store=crashed):
|
|
132
|
+
await asyncio.sleep(0.05)
|
|
133
|
+
script.no_call()
|
|
134
|
+
[(marked, doc)] = run_rows(crashed)
|
|
135
|
+
assert marked and doc["~parked"] is True and doc["outbox"] is not None
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def node(parent, role, *, leaf, active=True):
|
|
139
|
+
return {"parentId": parent, "role": role, "isLeaf": leaf, "onActiveBranch": active}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
async def interrupted_rewind(command: str, params: dict, thread: dict) -> MemoryStateStore:
|
|
143
|
+
"""An unapplied edit or reload in flight when the instance crashed."""
|
|
144
|
+
script = Script()
|
|
145
|
+
script.thread.update(thread)
|
|
146
|
+
store = MemoryStateStore()
|
|
147
|
+
async with run_host(script, store=store, capabilities=("rewind",)) as (drv, host):
|
|
148
|
+
drv.post(command, params)
|
|
149
|
+
await script.next_call()
|
|
150
|
+
await host.live.frontier.wait()
|
|
151
|
+
return survivors(store)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
async def test_an_unapplied_edit_whose_rewound_parent_left_the_branch_is_refused():
|
|
155
|
+
thread = {"a0": node(None, "assistant", leaf=False), "u1": node("a0", "user", leaf=True)}
|
|
156
|
+
crashed = await interrupted_rewind(
|
|
157
|
+
"run/edit", edit_params("u1", msg("u2"), anchor="a0"), thread
|
|
158
|
+
)
|
|
159
|
+
script = Script()
|
|
160
|
+
script.thread.update({**thread, "a0": node(None, "assistant", leaf=False, active=False)})
|
|
161
|
+
await assert_refused(crashed, script, capabilities=("rewind",))
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
async def test_an_unapplied_reload_whose_rewound_parent_left_the_branch_is_refused():
|
|
165
|
+
thread = {"u1": node(None, "user", leaf=False), "a1": node("u1", "assistant", leaf=True)}
|
|
166
|
+
crashed = await interrupted_rewind(
|
|
167
|
+
"run/reload", reload_params("a1", anchor="u1"), thread
|
|
168
|
+
)
|
|
169
|
+
script = Script()
|
|
170
|
+
script.thread.update({**thread, "u1": node(None, "user", leaf=False, active=False)})
|
|
171
|
+
await assert_refused(crashed, script, capabilities=("rewind",))
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
async def test_an_unapplied_edit_with_its_parent_still_active_redelivers():
|
|
175
|
+
thread = {"a0": node(None, "assistant", leaf=False), "u1": node("a0", "user", leaf=True)}
|
|
176
|
+
crashed = await interrupted_rewind(
|
|
177
|
+
"run/edit", edit_params("u1", msg("u2"), anchor="a0"), thread
|
|
178
|
+
)
|
|
179
|
+
script = Script()
|
|
180
|
+
script.thread.update(thread)
|
|
181
|
+
async with run_host(script, store=crashed, capabilities=("rewind",)):
|
|
182
|
+
call = await script.next_call()
|
|
183
|
+
assert call.ctx.attempts == 2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/deepagents_host.py
RENAMED
|
File without changes
|
{harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/fenced_postgres.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/providers/__init__.py
RENAMED
|
File without changes
|
{harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/src/harness_sdk/providers/gpt_live.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_deepagents_multi_approval.py
RENAMED
|
File without changes
|
|
File without changes
|
{harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_deepagents_subagent_approval.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{harness_sdk_python-0.40.11 → harness_sdk_python-0.40.12}/tests/test_example_local_origin.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|