harness-sdk-python 0.40.3__tar.gz → 0.40.8__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.
Files changed (78) hide show
  1. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/PKG-INFO +8 -8
  2. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/README.md +5 -5
  3. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/examples/runs_app.py +3 -3
  4. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/pyproject.toml +3 -3
  5. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/deepagents.py +80 -9
  6. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/deepagents_host.py +11 -1
  7. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/langgraph.py +1 -1
  8. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/run_manager.py +53 -47
  9. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/threads.py +1 -1
  10. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/voice.py +1 -1
  11. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/run_helpers.py +3 -3
  12. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_admit_steer.py +5 -5
  13. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_checkpoints.py +5 -1
  14. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_deepagents_approval.py +5 -5
  15. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_deepagents_files.py +3 -3
  16. harness_sdk_python-0.40.8/tests/test_deepagents_multi_approval.py +203 -0
  17. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_deepagents_outcome.py +4 -4
  18. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_deepagents_thread.py +4 -4
  19. harness_sdk_python-0.40.8/tests/test_deepagents_user_ids.py +137 -0
  20. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_deepagents_voice.py +6 -6
  21. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_durability.py +1 -1
  22. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_fenced_postgres.py +13 -9
  23. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_langgraph.py +3 -3
  24. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_mint_concurrency.py +1 -1
  25. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_prioritize.py +5 -4
  26. harness_sdk_python-0.40.8/tests/test_request_options.py +43 -0
  27. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_restore.py +1 -1
  28. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_run_admission.py +1 -1
  29. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_run_crash_sweep.py +1 -1
  30. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_run_eviction.py +4 -4
  31. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_run_id_bounds.py +14 -2
  32. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_run_ownership.py +126 -117
  33. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_run_sync.py +4 -6
  34. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_threads.py +9 -9
  35. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_undo.py +10 -16
  36. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_voice.py +1 -1
  37. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_wire.py +3 -3
  38. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/voice_helpers.py +3 -3
  39. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/.gitignore +0 -0
  40. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/examples/__init__.py +0 -0
  41. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/__init__.py +0 -0
  42. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/checkpoints.py +0 -0
  43. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/fenced_postgres.py +0 -0
  44. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/interest.py +0 -0
  45. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/linear_thread.py +0 -0
  46. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/messages.py +0 -0
  47. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/parts.py +0 -0
  48. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/prioritize.py +0 -0
  49. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/protocol.py +0 -0
  50. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/providers/__init__.py +0 -0
  51. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/providers/gpt_live.py +0 -0
  52. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/voice_thread.py +0 -0
  53. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/src/harness_sdk/wire.py +0 -0
  54. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_applied_visibility.py +0 -0
  55. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_batches.py +0 -0
  56. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_branch_anchor.py +0 -0
  57. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_dispatching.py +0 -0
  58. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_edit_dispatched.py +0 -0
  59. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_edit_reload.py +0 -0
  60. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_enqueue.py +0 -0
  61. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_gpt_live.py +0 -0
  62. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_imports.py +0 -0
  63. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_input_required.py +0 -0
  64. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_interest.py +0 -0
  65. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_linear_thread.py +0 -0
  66. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_meta.py +0 -0
  67. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_outcomes.py +0 -0
  68. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_parts.py +0 -0
  69. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_placement.py +0 -0
  70. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_prepare_hooks.py +0 -0
  71. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_prioritize_builtins.py +0 -0
  72. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_rewind_during_run.py +0 -0
  73. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_settle.py +0 -0
  74. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_steer.py +0 -0
  75. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_stop_continue.py +0 -0
  76. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_stopping_window.py +0 -0
  77. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_voice_delegation.py +0 -0
  78. {harness_sdk_python-0.40.3 → harness_sdk_python-0.40.8}/tests/test_voice_events.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: harness-sdk-python
3
- Version: 0.40.3
3
+ Version: 0.40.8
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: pinned>=0.17.0
9
- Requires-Dist: statewire<0.24,>=0.23.5
8
+ Requires-Dist: pinboard-sdk>=0.18.0
9
+ Requires-Dist: statewire<0.24,>=0.23.6
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'
@@ -26,7 +26,7 @@ Description-Content-Type: text/markdown
26
26
 
27
27
  # harness-sdk-python
28
28
 
29
- The runs subsystem for Python Statewire hosts: `@run_manager` turns one async method into the run executor and mounts the `run/*` command surface (send, dequeue, edit, reload, stop, continue, input), each run in its own tray. Part of [harness-sdk](https://github.com/assistant-ui/harness-sdk), with `statewire` and `pinned`.
29
+ The runs subsystem for Python Statewire hosts: `@run_manager` turns one async method into the run executor and mounts the `run/*` command surface (send, dequeue, edit, reload, stop, continue, input), each run in its own tray. Part of [harness-sdk](https://github.com/assistant-ui/harness-sdk), with `statewire` and Pinboard.
30
30
 
31
31
  ## Install
32
32
 
@@ -88,7 +88,7 @@ async def run(self, ctx: RunManager.RunContext): ...
88
88
 
89
89
  ## Docs
90
90
 
91
- - Get started: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/get-started/chat-app/page.mdx
92
- - Guide: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/guides/harness/host/page.mdx
93
- - Reference: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/reference/harness-sdk-python/page.mdx
94
- - Spec: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/spec/runs-protocol/page.mdx
91
+ - Get started: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/get-started/chat-app/page.mdx
92
+ - Guide: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/guides/harness/host/page.mdx
93
+ - Reference: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/reference/harness-sdk-python/page.mdx
94
+ - Spec: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/spec/runs-protocol/page.mdx
@@ -1,6 +1,6 @@
1
1
  # harness-sdk-python
2
2
 
3
- The runs subsystem for Python Statewire hosts: `@run_manager` turns one async method into the run executor and mounts the `run/*` command surface (send, dequeue, edit, reload, stop, continue, input), each run in its own tray. Part of [harness-sdk](https://github.com/assistant-ui/harness-sdk), with `statewire` and `pinned`.
3
+ The runs subsystem for Python Statewire hosts: `@run_manager` turns one async method into the run executor and mounts the `run/*` command surface (send, dequeue, edit, reload, stop, continue, input), each run in its own tray. Part of [harness-sdk](https://github.com/assistant-ui/harness-sdk), with `statewire` and Pinboard.
4
4
 
5
5
  ## Install
6
6
 
@@ -62,7 +62,7 @@ async def run(self, ctx: RunManager.RunContext): ...
62
62
 
63
63
  ## Docs
64
64
 
65
- - Get started: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/get-started/chat-app/page.mdx
66
- - Guide: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/guides/harness/host/page.mdx
67
- - Reference: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/reference/harness-sdk-python/page.mdx
68
- - Spec: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/spec/runs-protocol/page.mdx
65
+ - Get started: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/get-started/chat-app/page.mdx
66
+ - Guide: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/guides/harness/host/page.mdx
67
+ - Reference: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/reference/harness-sdk-python/page.mdx
68
+ - Spec: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/src/app/docs/spec/runs-protocol/page.mdx
@@ -19,8 +19,8 @@ from typing import Any
19
19
 
20
20
  from fastapi import FastAPI
21
21
  from langchain_core.messages import AIMessage, HumanMessage, ToolMessage
22
- from pinned import PinnedWorker
23
- from pinned.durability import MemoryStateStore
22
+ from pinboard import Worker
23
+ from pinboard.durability import MemoryStateStore
24
24
  from statewire import Statewire, command, plain
25
25
  from statewire.langgraph import append_langgraph_event
26
26
 
@@ -191,6 +191,6 @@ class RunsHost(Statewire):
191
191
  return await self.run.input(params, auth_result=auth_result)
192
192
 
193
193
 
194
- worker = PinnedWorker(hosts={"/threads": RunsHost}, state_store=MemoryStateStore())
194
+ worker = Worker(hosts={"/threads": RunsHost}, state_store=MemoryStateStore())
195
195
  app = FastAPI()
196
196
  app.include_router(worker)
@@ -1,11 +1,11 @@
1
1
  [project]
2
2
  name = "harness-sdk-python"
3
- version = "0.40.3"
3
+ version = "0.40.8"
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.23.5,<0.24", "pinned>=0.17.0"]
8
+ dependencies = ["statewire>=0.23.6,<0.24", "pinboard-sdk>=0.18.0"]
9
9
 
10
10
  [project.optional-dependencies]
11
11
  postgres = ["langgraph-checkpoint-postgres>=2.0.0"]
@@ -25,7 +25,7 @@ Repository = "https://github.com/assistant-ui/harness-sdk"
25
25
 
26
26
  [tool.uv.sources]
27
27
  statewire = { workspace = true }
28
- pinned = { workspace = true }
28
+ pinboard-sdk = { workspace = true }
29
29
 
30
30
  [build-system]
31
31
  requires = ["hatchling"]
@@ -7,6 +7,7 @@ namespace on the langgraph thread ``<thread_id>/<ns>``, concurrent with the
7
7
  main run; its rows persist under ``checkpoint_ns == ns``.
8
8
  """
9
9
 
10
+ import logging
10
11
  from typing import Any, Callable
11
12
 
12
13
  from statepatch import plain
@@ -22,6 +23,8 @@ from .messages import MAIN_NS, MessageTree
22
23
  from .parts import PartsAssembler, text_of
23
24
  from .voice_thread import upsert_voice_turn
24
25
 
26
+ logger = logging.getLogger(__name__)
27
+
25
28
  _TYPE_TO_ROLE = {"human": "user", "ai": "assistant", "tool": "assistant", "system": "assistant"}
26
29
 
27
30
 
@@ -172,9 +175,13 @@ class DeepagentsThread:
172
175
  self._mount(MAIN_NS, thread.head)
173
176
  if ctx.resume:
174
177
  return None, config
178
+ # The middleware reads decisions positionally, in tool_calls order:
179
+ # the head's tool parts carry that order, the outcomes may not.
180
+ order = [p.get("toolInvocationId") for p in plain(self.tree.get(MAIN_NS, thread.head)["parts"])]
181
+ outcomes = sorted(ctx.input_outcomes, key=lambda o: order.index(o[0]["toolCallId"]))
175
182
  decisions = [
176
183
  {"type": "approve"} if response and response.get("decision") == "approve" else {"type": "reject"}
177
- for _request, response, _meta in ctx.input_outcomes
184
+ for _request, response, _meta in outcomes
178
185
  ]
179
186
  self._admission = ctx.applied()
180
187
  return Command(resume={"decisions": decisions}), config
@@ -199,7 +206,7 @@ class DeepagentsThread:
199
206
  from langchain_core.messages import HumanMessage
200
207
 
201
208
  turn: list[Any] = [*plan.replay]
202
- for message in ctx.messages:
209
+ for message in self._without_agent_ids(ctx.messages):
203
210
  turn.append(HumanMessage(id=message["id"], content=_user_content(message)))
204
211
  self._append_user(message, parent)
205
212
  parent = message["id"]
@@ -218,6 +225,33 @@ class DeepagentsThread:
218
225
  self._changed()
219
226
  return ({"messages": turn} if turn else None), config
220
227
 
228
+ def _agent_ids(self) -> set[str]:
229
+ # user messages mount on the main graph; a subagent runs on its own
230
+ # LangGraph thread, so only main-namespace ids can collide
231
+ main = self.tree.threads.get(MAIN_NS)
232
+ messages = main.messages.values() if main is not None else ()
233
+ return {id for m in messages for id in _provider_ids(m)}
234
+
235
+ def check_user_id(self, message_id: Any) -> None:
236
+ """Reject a user message id that names a message the agent wrote: the
237
+ harness id becomes the LangChain id, and ``add_messages`` replaces a
238
+ message with the same id. Called per command at intake, so only the
239
+ offending send fails."""
240
+ if isinstance(message_id, str) and message_id in self._agent_ids():
241
+ raise StatewireReject(f"message id {message_id} is already used", payload={"reason": "duplicate-id"})
242
+
243
+ def _without_agent_ids(self, messages: Any) -> list[Any]:
244
+ """Dispatch-time guard for an id the agent wrote after the send's
245
+ intake check: drop only that message, keep the run and the rest."""
246
+ taken = self._agent_ids()
247
+ kept = []
248
+ for message in messages:
249
+ if message["id"] in taken:
250
+ logger.warning("dropping user message %r: the agent wrote a message with that id", message["id"])
251
+ else:
252
+ kept.append(message)
253
+ return kept
254
+
221
255
  def _append_user(self, message: dict[str, Any], parent: str | None) -> None:
222
256
  if self.tree.get(MAIN_NS, message["id"]) is not None:
223
257
  return
@@ -236,6 +270,7 @@ class DeepagentsThread:
236
270
  """Append steered user messages after the head; returns the langgraph turn entries."""
237
271
  from langchain_core.messages import HumanMessage
238
272
 
273
+ messages = self._without_agent_ids(messages)
239
274
  thread = self.tree.thread(MAIN_NS)
240
275
  turn = []
241
276
  for message in messages:
@@ -358,12 +393,14 @@ class DeepagentsThread:
358
393
  return
359
394
  if mode == "updates" and isinstance(event, dict) and "__interrupt__" in event and ns == MAIN_NS:
360
395
  assembler = self._assemblers.get(MAIN_NS)
361
- waiting = assembler.streaming_tools() if assembler is not None else []
362
- if waiting:
363
- tool_id = waiting[-1]
396
+ # no streamed message: still validate, so an unmatched interrupt fails the run
397
+ parts = plain(assembler.parts) if assembler is not None else []
398
+ tool_ids = _pending_tool_ids(parts, event["__interrupt__"])
399
+ for tool_id in tool_ids:
400
+ assert assembler is not None
364
401
  assembler.amend(tool_id, state="pendingApproval")
365
- self.interrupt = {"toolCallId": tool_id}
366
- self._changed()
402
+ self.interrupt = {"toolCallIds": tool_ids}
403
+ self._changed()
367
404
 
368
405
  def _finish(self, ns: str, outcome: dict[str, Any] | None = None) -> None:
369
406
  assembler = self._assemblers.pop(ns, None)
@@ -482,6 +519,40 @@ class DeepagentsThread:
482
519
  self._thread.abandon_plan()
483
520
 
484
521
 
522
+ def _pending_tool_ids(parts: list[dict[str, Any]], interrupts: Any) -> list[str]:
523
+ """The tool call ids a HumanInTheLoopMiddleware interrupt asks about, in
524
+ ``action_requests`` order. The middleware lists the reviewed calls of the
525
+ last AI message in ``tool_calls`` order and carries no ids, so each request
526
+ matches the next streaming tool part with the same name and args. An
527
+ interrupt that does not match raises: approving a guessed call is unsafe."""
528
+ requests: list[Any] = []
529
+ for interrupt in interrupts:
530
+ value = getattr(interrupt, "value", None)
531
+ action_requests = value.get("action_requests") if isinstance(value, dict) else None
532
+ if not isinstance(action_requests, list) or not action_requests:
533
+ raise ValueError("unsupported interrupt: expected HumanInTheLoopMiddleware action_requests")
534
+ requests.extend(action_requests)
535
+ waiting = [p for p in parts if p["type"] == "tool" and p["state"] == "streaming"]
536
+ tool_ids: list[str] = []
537
+ for request in requests:
538
+ if not isinstance(request, dict):
539
+ raise ValueError("unsupported interrupt: action request is not an object")
540
+ while waiting:
541
+ part = waiting.pop(0)
542
+ if part["toolName"] == request.get("name") and part.get("input") == request.get("args"):
543
+ tool_ids.append(part["toolInvocationId"])
544
+ break
545
+ else:
546
+ raise ValueError(f"interrupt asks about a {request.get('name')!r} call this turn did not stream")
547
+ return tool_ids
548
+
549
+
485
550
  def _provider_ids(message: Any) -> list[str]:
486
- metadata = plain(message.get("metadata")) or {}
487
- return list((metadata.get("provider") or {}).get("ids") or [])
551
+ """The LangChain ids an agent message folds. A user message's metadata is
552
+ the client's, so it names none."""
553
+ if message is None or message.get("role") == "user":
554
+ return []
555
+ metadata = plain(message.get("metadata"))
556
+ provider = metadata.get("provider") if isinstance(metadata, dict) else None
557
+ ids = provider.get("ids") if isinstance(provider, dict) else None
558
+ return [i for i in ids if isinstance(i, str)] if isinstance(ids, list) else []
@@ -153,7 +153,10 @@ class DeepagentsHost(VoiceThread, HarnessMessages, Statewire):
153
153
  interrupt = self.messages.interrupt
154
154
  if interrupt is not None:
155
155
  return RunManager.InputRequired(
156
- ({"id": interrupt["toolCallId"], "type": "tool-approval", "toolCallId": interrupt["toolCallId"]},)
156
+ tuple(
157
+ {"id": tool_id, "type": "tool-approval", "toolCallId": tool_id}
158
+ for tool_id in interrupt["toolCallIds"]
159
+ )
157
160
  )
158
161
  steered = self.messages.append_users(ctx.steering.take())
159
162
  if not steered:
@@ -187,8 +190,14 @@ class DeepagentsHost(VoiceThread, HarnessMessages, Statewire):
187
190
  with contextlib.suppress(Exception):
188
191
  await stream.aclose()
189
192
 
193
+ def _check_user_message(self, params: Any) -> None:
194
+ message = params.get("message") if isinstance(params, dict) else None
195
+ if isinstance(message, dict):
196
+ self.messages.check_user_id(message.get("id"))
197
+
190
198
  @command("run/send")
191
199
  async def run_send(self, params, *, ctx, auth_result):
200
+ self._check_user_message(params)
192
201
  return await self.run.send(params, applied=ctx.applied, auth_result=auth_result, version=ctx.version)
193
202
 
194
203
  @command("run/dequeue")
@@ -197,6 +206,7 @@ class DeepagentsHost(VoiceThread, HarnessMessages, Statewire):
197
206
 
198
207
  @command("run/edit")
199
208
  async def run_edit(self, params, *, ctx, auth_result):
209
+ self._check_user_message(params)
200
210
  return await self.run.edit(params, applied=ctx.applied, auth_result=auth_result)
201
211
 
202
212
  @command("run/reload")
@@ -1,7 +1,7 @@
1
1
  from typing import Any, AsyncIterator, Awaitable, Callable
2
2
 
3
3
  from langgraph.checkpoint.base import BaseCheckpointSaver
4
- from pinned import Frontier
4
+ from pinboard import Frontier
5
5
 
6
6
 
7
7
  class FrontierCheckpointer(BaseCheckpointSaver):
@@ -52,20 +52,14 @@ so a settled stop covers every durable effect the runner enlisted. On run end
52
52
  one envelope promotes ``nextDispatch`` into ``dispatching`` and clears the
53
53
  window.
54
54
 
55
- Ownership: the machine records the principal (the command's ``auth_result``)
56
- that minted it, and each queued message records its author's. ``run/stop``,
57
- ``run/edit``, ``run/reload``, ``run/continue``, and ``run/input`` are
58
- restricted to the run's principal; a queued message's dequeue, rewrite, and
59
- move to its author. Message ids stay bound to their first author for the
60
- machine's lifetime: a dequeued id re-enters only under its author. Both
61
- records persist and survive restarts, and a recorded principal is never
62
- overwritten. A ``None`` recorded principal leaves the mutation open — a host
63
- whose ``authorize`` returns ``None`` keeps client-trusting behavior, and a
64
- machine whose first admission is a pooled command replayed cold after a
65
- restart records no principal (such replays run with ``auth_result`` ``None``
66
- per the statewire replay contract). Principals stay off the wire
67
- projections; ``authorize`` must return a JSON-serializable value with stable
68
- equality per principal.
55
+ Run control: every attached caller may stop, continue, edit, reload, answer
56
+ input on, and preempt or steer the run, and dequeue, rewrite, or move any
57
+ queued message. Attach authorization is the gate; a finer security-gate
58
+ system is planned. The machine still records the minting caller's
59
+ ``auth_result`` as ``principal`` and each queued message's as ``authors``
60
+ (persisted state kept for compatibility; ``authors`` also counts toward the
61
+ tracked-id capacity), but neither is enforced. Principals stay off the wire
62
+ projections.
69
63
  """
70
64
 
71
65
  import asyncio
@@ -83,10 +77,10 @@ from typing import (
83
77
  Protocol,
84
78
  )
85
79
 
86
- from pinned import EvictionRequested
87
- from pinned.durability import FenceLost
88
- from pinned.trays import Tray, TrayDescriptor, TrayCtx, TrayMapNamespace, inbox
89
- from pinned.trays import persistent, persistent_outbox, persistent_queue
80
+ from pinboard import EvictionRequested
81
+ from pinboard.durability import FenceLost
82
+ from pinboard.trays import Tray, TrayDescriptor, TrayCtx, TrayMapNamespace, inbox
83
+ from pinboard.trays import persistent, persistent_outbox, persistent_queue
90
84
  from statepatch import observable
91
85
  from statewire import StatewireReject
92
86
  from statewire.api import (
@@ -100,6 +94,7 @@ from statewire.ops import encode_envelope
100
94
  logger = logging.getLogger(__name__)
101
95
 
102
96
  MAX_MESSAGE_ID_LENGTH = 256
97
+ MAX_RUN_ID_LENGTH = 256
103
98
  MAX_MESSAGE_BYTES = 1 << 20
104
99
  MAX_RUN_IDS = 4096
105
100
 
@@ -172,9 +167,22 @@ def _run_id_of(params: Any) -> str:
172
167
  run_id = params.get("runId") if isinstance(params, dict) else None
173
168
  if not isinstance(run_id, str) or run_id == "":
174
169
  raise _reject("invalid-message", "runId must be a non-empty string")
170
+ # the run id becomes the machine's tray id, a primary-key column in the store
171
+ if len(run_id) > MAX_RUN_ID_LENGTH:
172
+ raise _reject(
173
+ "invalid-message", f"runId exceeds {MAX_RUN_ID_LENGTH} characters"
174
+ )
175
175
  return run_id
176
176
 
177
177
 
178
+ def _refuse_request_options(params: Any) -> None:
179
+ if isinstance(params, dict) and "requestOptions" in params:
180
+ raise _reject(
181
+ "capability-missing",
182
+ "requestOptions is accepted only by the AI SDK transport",
183
+ )
184
+
185
+
178
186
  def _prepared(
179
187
  hook: Callable[[dict[str, Any]], dict[str, Any]] | None,
180
188
  name: str,
@@ -430,6 +438,7 @@ class RunManager(Tray):
430
438
 
431
439
  queue = persistent_queue()
432
440
  steerQueue = persistent_queue()
441
+ # Recorded but not enforced; kept so persisted state keeps its shape.
433
442
  principal = persistent(None) # the minting caller's auth_result; never on the wire
434
443
  authors = persistent({}) # message id -> the enqueueing caller's auth_result
435
444
  outbox = persistent_outbox() # {"record": ..., "lanes": [...]}: the in-flight dispatch
@@ -610,19 +619,6 @@ class RunManager(Tray):
610
619
 
611
620
  # ─── State access ───────────────────────────────────────
612
621
 
613
- def _check_owner(self, recorded: Any, principal: Any, what: str) -> None:
614
- # a None record is unbound: a host without authorize keeps legacy behavior
615
- if recorded is not None and recorded != principal:
616
- raise _reject("not-owner", f"{what} belongs to another caller")
617
-
618
- def _check_run_owner(self, principal: Any) -> None:
619
- self._check_owner(self.principal.value, principal, f"run {self.id}")
620
-
621
- def _check_author(self, message_id: str, principal: Any) -> None:
622
- self._check_owner(
623
- self.authors.value.get(message_id), principal, f"message {message_id}"
624
- )
625
-
626
622
  def _in_flight(self) -> bool:
627
623
  return self.outbox.value is not None
628
624
 
@@ -1656,7 +1652,8 @@ class RunManager(Tray):
1656
1652
  return self._apply_move(e, fx)
1657
1653
  current = self._lane_of(e.message_id)
1658
1654
  if current is not None:
1659
- self._check_author(e.message_id, e.principal)
1655
+ # Run control is open to every attached caller; attach authorization is the
1656
+ # gate. A finer security-gate system is planned.
1660
1657
  self._check_anchor(e)
1661
1658
  self._place(e.lane, current, e.message, e.params, e.meta)
1662
1659
  if e.lane == "steerQueue":
@@ -1674,8 +1671,8 @@ class RunManager(Tray):
1674
1671
  raise _reject("invalid-message", "runAnchorMessageId is required")
1675
1672
  else:
1676
1673
  self._check_anchor(e)
1677
- # ids stay bound to their first author: a dequeued id re-enters authors-only
1678
- self._check_author(e.message_id, e.principal)
1674
+ # Run control is open to every attached caller; attach authorization is the
1675
+ # gate. A finer security-gate system is planned.
1679
1676
  self._check_id_capacity((e.message_id,))
1680
1677
  if self._dispatchable(e.lane):
1681
1678
  self._stage_batch(e)
@@ -1704,7 +1701,8 @@ class RunManager(Tray):
1704
1701
  f"message {e.message_id} already dispatched",
1705
1702
  )
1706
1703
  raise _reject("unknown-id", f"message {e.message_id} is not queued")
1707
- self._check_author(e.message_id, e.principal)
1704
+ # Run control is open to every attached caller; attach authorization is the
1705
+ # gate. A finer security-gate system is planned.
1708
1706
  item = next(i for i in self._lane_items(current) if i["id"] == e.message_id)
1709
1707
  self._place(e.lane, current, item, e.params, item.get("meta"))
1710
1708
  if e.lane == "steerQueue":
@@ -1749,7 +1747,8 @@ class RunManager(Tray):
1749
1747
 
1750
1748
  def _park_dispatched_edit(self, e: _Send) -> Any:
1751
1749
  assert e.message is not None
1752
- self._check_run_owner(e.principal)
1750
+ # Run control is open to every attached caller; attach authorization is the
1751
+ # gate. A finer security-gate system is planned.
1753
1752
  _check_rewind_gate(self.capabilities, self._in_flight(), "editing")
1754
1753
  if e.source_meta is None:
1755
1754
  raise _reject("unknown-id", f"message {e.message_id} is unknown")
@@ -1769,8 +1768,8 @@ class RunManager(Tray):
1769
1768
  lane = self._lane_of(e.message_id)
1770
1769
  if lane is None:
1771
1770
  raise _reject("unknown-id", f"message {e.message_id} is not queued")
1772
- if e.principal != self.principal.value or self.principal.value is None:
1773
- self._check_author(e.message_id, e.principal)
1771
+ # Run control is open to every attached caller; attach authorization is the
1772
+ # gate. A finer security-gate system is planned.
1774
1773
  self._lane(lane).value = [
1775
1774
  item for item in self._lane_items(lane) if item["id"] != e.message_id
1776
1775
  ]
@@ -1780,7 +1779,8 @@ class RunManager(Tray):
1780
1779
  def _apply_input(self, e: _Input) -> Any:
1781
1780
  if self._status() != "input-required":
1782
1781
  raise _reject("wrong-state", f"run/input is rejected in {self._status()}")
1783
- self._check_run_owner(e.principal)
1782
+ # Run control is open to every attached caller; attach authorization is the
1783
+ # gate. A finer security-gate system is planned.
1784
1784
  index = next(
1785
1785
  (
1786
1786
  i
@@ -1808,7 +1808,8 @@ class RunManager(Tray):
1808
1808
  return None
1809
1809
 
1810
1810
  def _apply_edit(self, e: _Edit) -> Any:
1811
- self._check_run_owner(e.principal)
1811
+ # Run control is open to every attached caller; attach authorization is the
1812
+ # gate. A finer security-gate system is planned.
1812
1813
  self._check_id_capacity((e.message["id"],))
1813
1814
  staged = self._staged_rewind
1814
1815
  if (
@@ -1830,7 +1831,8 @@ class RunManager(Tray):
1830
1831
  return _PARKED
1831
1832
 
1832
1833
  def _apply_reload(self, e: _Reload) -> Any:
1833
- self._check_run_owner(e.principal)
1834
+ # Run control is open to every attached caller; attach authorization is the
1835
+ # gate. A finer security-gate system is planned.
1834
1836
  if self._staged_rewind is not None:
1835
1837
  raise _reject("wrong-state", "a rewind is already staged")
1836
1838
  self._stage_rewind(
@@ -1876,7 +1878,8 @@ class RunManager(Tray):
1876
1878
  status == "stopping" and stop_held
1877
1879
  ):
1878
1880
  raise _reject("wrong-state", f"run/stop is rejected in {status}")
1879
- self._check_run_owner(auth_result)
1881
+ # Run control is open to every attached caller; attach authorization is the
1882
+ # gate. A finer security-gate system is planned.
1880
1883
  run_id = _run_id_of(params)
1881
1884
  if run_id != self.id:
1882
1885
  raise _reject(
@@ -1905,7 +1908,8 @@ class RunManager(Tray):
1905
1908
  status = self._status()
1906
1909
  if status not in ("error", "stopped"):
1907
1910
  raise _reject("wrong-state", f"run/continue is rejected in {status}")
1908
- self._check_run_owner(auth_result)
1911
+ # Run control is open to every attached caller; attach authorization is the
1912
+ # gate. A finer security-gate system is planned.
1909
1913
  if not self._lane_items("steerQueue") and (
1910
1914
  "incomplete-continuation" not in self.capabilities
1911
1915
  ):
@@ -2254,7 +2258,8 @@ class RunManagerNamespace(TrayMapNamespace):
2254
2258
  if not requests and not has_pending_tasks:
2255
2259
  return False
2256
2260
  tray, _ = await self._machine(self._api.domain.token_hex(16), principal)
2257
- tray._check_run_owner(principal)
2261
+ # Run control is open to every attached caller; attach authorization is the
2262
+ # gate. A finer security-gate system is planned.
2258
2263
  if (
2259
2264
  tray._in_flight()
2260
2265
  or tray._intake
@@ -2390,6 +2395,7 @@ class RunManagerNamespace(TrayMapNamespace):
2390
2395
  cls: type[RunManager] = self._spec.tray_cls # type: ignore[assignment]
2391
2396
  if not isinstance(params, dict):
2392
2397
  raise _reject("invalid-message", "params must be an object")
2398
+ _refuse_request_options(params)
2393
2399
  run_id = _run_id_of(params)
2394
2400
  behavior = params.get("behavior", "auto")
2395
2401
  if behavior not in _BEHAVIORS:
@@ -2527,15 +2533,13 @@ class RunManagerNamespace(TrayMapNamespace):
2527
2533
  behavior: str,
2528
2534
  message: dict[str, Any] | None,
2529
2535
  message_id: str,
2530
- principal: Any,
2536
+ principal: Any, # unused: run control is open to every attached caller
2531
2537
  ) -> dict[str, Any] | None:
2532
2538
  """The message an auto send consults the prioritizer on; None stages without one."""
2533
2539
  cls: type[RunManager] = self._spec.tray_cls # type: ignore[assignment]
2534
2540
  if behavior != "auto" or cls.prioritize is None or tray._status() not in _LIVE:
2535
2541
  return None
2536
2542
  lane = tray._lane_of(message_id)
2537
- if lane is not None:
2538
- tray._check_author(message_id, principal) # before the prioritizer sees it
2539
2543
  if message is not None:
2540
2544
  return message
2541
2545
  if lane is None:
@@ -2606,6 +2610,7 @@ class RunManagerNamespace(TrayMapNamespace):
2606
2610
  ) -> Any:
2607
2611
  cls: type[RunManager] = self._spec.tray_cls # type: ignore[assignment]
2608
2612
  self._check_rewind_gate("run/edit")
2613
+ _refuse_request_options(params)
2609
2614
  run_id = _run_id_of(params)
2610
2615
  source_id = params.get("sourceId") if isinstance(params, dict) else None
2611
2616
  if not isinstance(source_id, str):
@@ -2645,6 +2650,7 @@ class RunManagerNamespace(TrayMapNamespace):
2645
2650
  ) -> Any:
2646
2651
  cls: type[RunManager] = self._spec.tray_cls # type: ignore[assignment]
2647
2652
  self._check_rewind_gate("run/reload")
2653
+ _refuse_request_options(params)
2648
2654
  run_id = _run_id_of(params)
2649
2655
  source_id = params.get("sourceId") if isinstance(params, dict) else None
2650
2656
  if not isinstance(source_id, str):
@@ -8,7 +8,7 @@ from datetime import datetime, timezone
8
8
  from typing import Any, Literal, NotRequired, Protocol, TypedDict, get_args
9
9
 
10
10
  from fastapi import HTTPException, Request
11
- from pinned import Attestation, AuthRejected, attestation, route
11
+ from pinboard import Attestation, AuthRejected, attestation, route
12
12
  from starlette.requests import HTTPConnection
13
13
  from statewire import Statewire, StatewireReject, command
14
14
 
@@ -56,7 +56,7 @@ from time import monotonic
56
56
  from typing import Any, Callable, Literal, Protocol, TypedDict
57
57
  from uuid import uuid4
58
58
 
59
- from pinned.trays import Tray, TrayDescriptor, TrayMapNamespace
59
+ from pinboard.trays import Tray, TrayDescriptor, TrayMapNamespace
60
60
  from statepatch import observable, plain
61
61
  from statewire import StatewireReject
62
62
 
@@ -5,8 +5,8 @@ from dataclasses import dataclass
5
5
  from typing import Any
6
6
  from uuid import uuid4
7
7
 
8
- from pinned import PinnedWorker
9
- from pinned.testing import MemoryStateStore
8
+ from pinboard import Worker
9
+ from pinboard.testing import MemoryStateStore
10
10
  from statewire import Statewire, command
11
11
  from statewire.protocol import VERSION, Offer, Protocol, VersionRange
12
12
  from statewire.protocol import headers as protocol_headers
@@ -346,7 +346,7 @@ async def run_host(
346
346
  version=version,
347
347
  prioritize=prioritize,
348
348
  )
349
- worker = PinnedWorker(
349
+ worker = Worker(
350
350
  state_store=store if store is not None else MemoryStateStore()
351
351
  )
352
352
  async with statewire_client(host_cls, worker=worker) as (app, client):
@@ -9,8 +9,8 @@ import copy
9
9
 
10
10
  import pytest
11
11
 
12
- from pinned import PinnedWorker
13
- from pinned.testing import MemoryStateStore
12
+ from pinboard import Worker
13
+ from pinboard.testing import MemoryStateStore
14
14
  from run_helpers import Script, add, machine, msg
15
15
  from statewire_helpers import apply_ops, attach_of, post_frame, statewire_client
16
16
 
@@ -68,7 +68,7 @@ async def test_durable_dispatch_rejects_oversized_steer_before_mutation():
68
68
  script = Script()
69
69
  host = make_host(script)
70
70
  host.gate.set()
71
- async with statewire_client(host, worker=PinnedWorker(state_store=MemoryStateStore())) as (_app, client):
71
+ async with statewire_client(host, worker=Worker(state_store=MemoryStateStore())) as (_app, client):
72
72
  async with attach_of(_app, {"headers": {}}) as stream:
73
73
  await stream.next_event()
74
74
  frame = {"cmd": [statement(1, "run/steerDurable", {
@@ -91,7 +91,7 @@ async def test_admit_steer_admits_exactly_once_and_the_run_sees_no_tag(torn):
91
91
  store = MemoryStateStore()
92
92
  script = Script()
93
93
  host = make_host(script)
94
- async with statewire_client(host, worker=PinnedWorker(state_store=store)) as (
94
+ async with statewire_client(host, worker=Worker(state_store=store)) as (
95
95
  app,
96
96
  client,
97
97
  ):
@@ -118,7 +118,7 @@ async def test_admit_steer_admits_exactly_once_and_the_run_sees_no_tag(torn):
118
118
  script2 = Script()
119
119
  host2 = make_host(script2)
120
120
  host2.gate.set()
121
- async with statewire_client(host2, worker=PinnedWorker(state_store=store)) as (
121
+ async with statewire_client(host2, worker=Worker(state_store=store)) as (
122
122
  app,
123
123
  client,
124
124
  ):
@@ -709,6 +709,9 @@ def postgres_dsn():
709
709
  container = subprocess.run(
710
710
  [
711
711
  docker, "run", "--rm", "-d",
712
+ # the postgres image declares a VOLUME for its data dir; tmpfs keeps
713
+ # docker from creating an anonymous volume for every run.
714
+ "--tmpfs", "/var/lib/postgresql/data",
712
715
  "-e", "POSTGRES_PASSWORD=harness",
713
716
  "-p", f"127.0.0.1:{port}:5432",
714
717
  "postgres:16",
@@ -728,7 +731,8 @@ def postgres_dsn():
728
731
  raise RuntimeError(f"postgres at {dsn} did not become ready")
729
732
  yield dsn
730
733
  finally:
731
- subprocess.run([docker, "rm", "-f", container], capture_output=True)
734
+ # -v: `rm -f` alone skips --rm's volume cleanup.
735
+ subprocess.run([docker, "rm", "-fv", container], capture_output=True)
732
736
 
733
737
 
734
738
  @pytest.fixture(params=["conn", "pool"])