tempergraph 0.7.1__py3-none-any.whl
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.
- tempergraph/__init__.py +8 -0
- tempergraph/__main__.py +5 -0
- tempergraph/api.py +428 -0
- tempergraph/audit/__init__.py +305 -0
- tempergraph/audit/catalog.py +342 -0
- tempergraph/audit/definition.py +387 -0
- tempergraph/audit/history.py +414 -0
- tempergraph/audit/history_rules.py +268 -0
- tempergraph/audit/history_rules_more.py +244 -0
- tempergraph/audit/host.py +270 -0
- tempergraph/audit/owned.py +96 -0
- tempergraph/audit/prompts.py +89 -0
- tempergraph/audit/report.py +248 -0
- tempergraph/audit/revisit.py +220 -0
- tempergraph/audit/surface.py +224 -0
- tempergraph/audit/text_health.py +176 -0
- tempergraph/audit/tools.py +391 -0
- tempergraph/author/__init__.py +2 -0
- tempergraph/author/blueprint.py +346 -0
- tempergraph/author/compare.py +122 -0
- tempergraph/author/criteria_lint.py +200 -0
- tempergraph/author/draw.py +112 -0
- tempergraph/author/inventory.py +210 -0
- tempergraph/author/literals.py +138 -0
- tempergraph/author/scaffold.py +568 -0
- tempergraph/author/session.py +439 -0
- tempergraph/author/trial.py +391 -0
- tempergraph/author/verify.py +353 -0
- tempergraph/builtin/__init__.py +1 -0
- tempergraph/builtin/upgrade.py +288 -0
- tempergraph/catalog.py +134 -0
- tempergraph/check_helpers.py +99 -0
- tempergraph/cli/__init__.py +1 -0
- tempergraph/cli/audit.py +190 -0
- tempergraph/cli/author.py +361 -0
- tempergraph/cli/improve.py +564 -0
- tempergraph/cli/improve_review.py +111 -0
- tempergraph/cli/install.py +35 -0
- tempergraph/cli/main.py +1261 -0
- tempergraph/cli/observe_cli.py +544 -0
- tempergraph/cli/outcome.py +77 -0
- tempergraph/cli/schedule_cli.py +1090 -0
- tempergraph/cli/upgrade.py +126 -0
- tempergraph/cli/workflows.py +96 -0
- tempergraph/compiler/__init__.py +6 -0
- tempergraph/compiler/graph.py +305 -0
- tempergraph/compiler/state.py +229 -0
- tempergraph/constants.py +72 -0
- tempergraph/contracts.py +1025 -0
- tempergraph/data/executor_compat.json +11 -0
- tempergraph/data/promotion.json +35 -0
- tempergraph/data/release.json +20 -0
- tempergraph/detach.py +65 -0
- tempergraph/docs.py +90 -0
- tempergraph/durability/__init__.py +2 -0
- tempergraph/durability/alias.py +66 -0
- tempergraph/durability/carry.py +591 -0
- tempergraph/durability/checkpoint.py +179 -0
- tempergraph/durability/control.py +109 -0
- tempergraph/durability/engine_file.py +301 -0
- tempergraph/durability/lock.py +138 -0
- tempergraph/durability/status.py +390 -0
- tempergraph/engine_identity.py +42 -0
- tempergraph/executor_compat.py +56 -0
- tempergraph/executors/__init__.py +4 -0
- tempergraph/executors/binding.py +91 -0
- tempergraph/executors/capabilities.py +95 -0
- tempergraph/executors/claude.py +603 -0
- tempergraph/executors/launcher.py +394 -0
- tempergraph/executors/mcpconfig.py +156 -0
- tempergraph/executors/mcpproxy.py +216 -0
- tempergraph/executors/preflight.py +196 -0
- tempergraph/executors/registry.py +71 -0
- tempergraph/executors/scripted.py +18 -0
- tempergraph/executors/session.py +107 -0
- tempergraph/executors/standins.py +118 -0
- tempergraph/executors/summary.py +110 -0
- tempergraph/executors/viewcatalog.py +27 -0
- tempergraph/git.py +403 -0
- tempergraph/identity.py +65 -0
- tempergraph/improve/__init__.py +5 -0
- tempergraph/improve/analysis.py +437 -0
- tempergraph/improve/artifact.py +477 -0
- tempergraph/improve/autonomy.py +192 -0
- tempergraph/improve/bindings.py +191 -0
- tempergraph/improve/calibration.py +1016 -0
- tempergraph/improve/causes.py +416 -0
- tempergraph/improve/child.py +651 -0
- tempergraph/improve/codehost.py +520 -0
- tempergraph/improve/digest.py +472 -0
- tempergraph/improve/escape.py +100 -0
- tempergraph/improve/filing.py +1047 -0
- tempergraph/improve/harvest.py +158 -0
- tempergraph/improve/issue_context.py +192 -0
- tempergraph/improve/lenses.py +204 -0
- tempergraph/improve/lessons.py +233 -0
- tempergraph/improve/loop_report.py +138 -0
- tempergraph/improve/loop_summary.py +85 -0
- tempergraph/improve/lost.py +119 -0
- tempergraph/improve/measure.py +121 -0
- tempergraph/improve/params.py +98 -0
- tempergraph/improve/pause_facts.py +134 -0
- tempergraph/improve/pr_later.py +186 -0
- tempergraph/improve/prebinding.py +130 -0
- tempergraph/improve/promotion.py +413 -0
- tempergraph/improve/proposals.py +934 -0
- tempergraph/improve/record.py +322 -0
- tempergraph/improve/release.py +89 -0
- tempergraph/improve/reliability.py +457 -0
- tempergraph/improve/repeat.py +115 -0
- tempergraph/improve/review.py +910 -0
- tempergraph/improve/suites.py +586 -0
- tempergraph/improve/trials.py +525 -0
- tempergraph/install/__init__.py +11 -0
- tempergraph/install/bootstrap.py +133 -0
- tempergraph/install/environment.py +173 -0
- tempergraph/install/launch.py +37 -0
- tempergraph/install/python.py +53 -0
- tempergraph/install/reconcile.py +52 -0
- tempergraph/install/selfcheck.py +29 -0
- tempergraph/install/shim.py +81 -0
- tempergraph/install/update.py +400 -0
- tempergraph/model/__init__.py +0 -0
- tempergraph/model/diagram.py +185 -0
- tempergraph/model/flow.py +324 -0
- tempergraph/model/prompt_lint.py +203 -0
- tempergraph/model/retire.py +52 -0
- tempergraph/model/subworkflow.py +274 -0
- tempergraph/model/text.py +67 -0
- tempergraph/model/validate.py +1158 -0
- tempergraph/observe/__init__.py +1 -0
- tempergraph/observe/attention.py +196 -0
- tempergraph/observe/detail.py +773 -0
- tempergraph/observe/forget.py +138 -0
- tempergraph/observe/hooks.py +272 -0
- tempergraph/observe/labels.py +95 -0
- tempergraph/observe/overlay.py +46 -0
- tempergraph/observe/report.py +402 -0
- tempergraph/observe/risk_report.py +110 -0
- tempergraph/observe/rows.py +444 -0
- tempergraph/observe/sinks.py +793 -0
- tempergraph/observe/supervision_cost.py +797 -0
- tempergraph/observe/supervision_report.py +295 -0
- tempergraph/observe/switch_report.py +140 -0
- tempergraph/package/__init__.py +2 -0
- tempergraph/package/change_report.py +116 -0
- tempergraph/package/changelog.py +263 -0
- tempergraph/package/docs_check.py +115 -0
- tempergraph/package/importer.py +90 -0
- tempergraph/package/inventory.py +111 -0
- tempergraph/package/loader.py +250 -0
- tempergraph/package/manifest.py +256 -0
- tempergraph/package/readiness.py +124 -0
- tempergraph/package/registry.py +383 -0
- tempergraph/package/rules.py +128 -0
- tempergraph/package/scan.py +65 -0
- tempergraph/package/selftest.py +348 -0
- tempergraph/package/stamp.py +213 -0
- tempergraph/package/transforms.py +481 -0
- tempergraph/package/upgrade.py +625 -0
- tempergraph/provenance.py +183 -0
- tempergraph/py.typed +0 -0
- tempergraph/release.py +17 -0
- tempergraph/render/__init__.py +0 -0
- tempergraph/render/output.py +72 -0
- tempergraph/render/prompt.py +166 -0
- tempergraph/render/template.py +86 -0
- tempergraph/run/__init__.py +2 -0
- tempergraph/run/asking.py +233 -0
- tempergraph/run/audit.py +63 -0
- tempergraph/run/check_worker.py +167 -0
- tempergraph/run/checks.py +517 -0
- tempergraph/run/commands.py +210 -0
- tempergraph/run/complexity.py +268 -0
- tempergraph/run/contest.py +76 -0
- tempergraph/run/council.py +368 -0
- tempergraph/run/council_run.py +527 -0
- tempergraph/run/events.py +279 -0
- tempergraph/run/finalize.py +132 -0
- tempergraph/run/gate.py +747 -0
- tempergraph/run/guard.py +89 -0
- tempergraph/run/judging.py +357 -0
- tempergraph/run/ladder.py +230 -0
- tempergraph/run/log.py +600 -0
- tempergraph/run/mapping.py +183 -0
- tempergraph/run/nodes.py +2304 -0
- tempergraph/run/outcome.py +255 -0
- tempergraph/run/outcome_record.py +292 -0
- tempergraph/run/outcome_trust.py +99 -0
- tempergraph/run/rerun.py +351 -0
- tempergraph/run/reserve.py +85 -0
- tempergraph/run/resources.py +76 -0
- tempergraph/run/risk.py +231 -0
- tempergraph/run/runner.py +1579 -0
- tempergraph/run/scriptcache.py +178 -0
- tempergraph/run/selfcheck.py +105 -0
- tempergraph/run/session_record.py +72 -0
- tempergraph/run/subrun.py +278 -0
- tempergraph/run/supervision.py +125 -0
- tempergraph/run/tool_access.py +101 -0
- tempergraph/schedule/__init__.py +25 -0
- tempergraph/schedule/credentials.py +167 -0
- tempergraph/schedule/echo.py +169 -0
- tempergraph/schedule/exact.py +275 -0
- tempergraph/schedule/export.py +164 -0
- tempergraph/schedule/launch.py +89 -0
- tempergraph/schedule/ledger.py +133 -0
- tempergraph/schedule/loop.py +176 -0
- tempergraph/schedule/model.py +440 -0
- tempergraph/schedule/policies.py +414 -0
- tempergraph/schedule/store.py +150 -0
- tempergraph/schedule/tick.py +377 -0
- tempergraph/schedule/token.py +81 -0
- tempergraph/schedule/triggers.py +210 -0
- tempergraph/schedule/words.py +423 -0
- tempergraph/security/__init__.py +0 -0
- tempergraph/security/launch.py +25 -0
- tempergraph/security/scrub.py +58 -0
- tempergraph/settings.py +950 -0
- tempergraph/store/__init__.py +0 -0
- tempergraph/store/codelog.py +73 -0
- tempergraph/store/layout.py +198 -0
- tempergraph/store/logs.py +325 -0
- tempergraph/store/manifest.py +99 -0
- tempergraph/store/migrate.py +188 -0
- tempergraph/workspace.py +874 -0
- tempergraph-0.7.1.dist-info/METADATA +70 -0
- tempergraph-0.7.1.dist-info/RECORD +232 -0
- tempergraph-0.7.1.dist-info/WHEEL +5 -0
- tempergraph-0.7.1.dist-info/entry_points.txt +5 -0
- tempergraph-0.7.1.dist-info/top_level.txt +2 -0
- tempergraph_pytest_plugin.py +64 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"""The judge's filtering MCP proxy (ECC-B3, ADR a-judge-reaches-an-mcp-server-only-through-the-engines-filtering-proxy).
|
|
2
|
+
|
|
3
|
+
A stdio MCP server that fronts one local MCP server of the operator's own configuration and offers only the viewed
|
|
4
|
+
tools of it: `tools/list` shows the allowed names, `tools/call` of any other name is answered with an error and never
|
|
5
|
+
forwarded, and every other request (resources, prompts, completion, logging) is refused, so what a judge can reach
|
|
6
|
+
is the viewed tools and nothing else. The engine never holds a connection of its own: the operator's server runs as
|
|
7
|
+
this process's child, with the environment its own definition gives.
|
|
8
|
+
|
|
9
|
+
Run as `python -m tempergraph.executors.mcpproxy --allow <tool> [--allow <tool> ...] -- <server command> [args]`.
|
|
10
|
+
Messages are newline-delimited JSON-RPC, as the stdio transport defines them.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import contextlib
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
import select
|
|
19
|
+
import subprocess
|
|
20
|
+
import sys
|
|
21
|
+
import threading
|
|
22
|
+
from collections.abc import Mapping, Sequence
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import IO, Any, TextIO
|
|
25
|
+
|
|
26
|
+
NOT_OFFERED = -32602
|
|
27
|
+
NOT_SUPPORTED = -32601
|
|
28
|
+
FORWARDED = ("initialize", "ping", "tools/list", "tools/call")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _error(msg_id: Any, code: int, text: str) -> dict[str, Any]:
|
|
32
|
+
return {"jsonrpc": "2.0", "id": msg_id, "error": {"code": code, "message": text}}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Proxy:
|
|
36
|
+
def __init__(self, allowed: Sequence[str], command: Sequence[str]) -> None:
|
|
37
|
+
self.allowed = frozenset(allowed)
|
|
38
|
+
self.command = list(command)
|
|
39
|
+
self._out_lock = threading.Lock()
|
|
40
|
+
self._lists: set[Any] = set() # ids of forwarded `tools/list` requests, whose answers are filtered
|
|
41
|
+
self._inits: set[Any] = set()
|
|
42
|
+
|
|
43
|
+
# -- output to the client ---------------------------------------------------------------------
|
|
44
|
+
|
|
45
|
+
def _emit(self, out: TextIO, msg: dict[str, Any]) -> None:
|
|
46
|
+
with self._out_lock:
|
|
47
|
+
out.write(json.dumps(msg) + "\n")
|
|
48
|
+
out.flush()
|
|
49
|
+
|
|
50
|
+
# -- client to server ---------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
def _from_client(self, line: str, child_in: IO[str], out: TextIO) -> None:
|
|
53
|
+
try:
|
|
54
|
+
msg = json.loads(line)
|
|
55
|
+
except ValueError:
|
|
56
|
+
return
|
|
57
|
+
if not isinstance(msg, dict):
|
|
58
|
+
return
|
|
59
|
+
method, msg_id = msg.get("method"), msg.get("id")
|
|
60
|
+
if method is None: # a reply to a server-initiated request: none is ever forwarded to the server
|
|
61
|
+
return
|
|
62
|
+
if msg_id is None: # a notification
|
|
63
|
+
if str(method).startswith("notifications/"):
|
|
64
|
+
self._send(child_in, msg)
|
|
65
|
+
return
|
|
66
|
+
if method not in FORWARDED:
|
|
67
|
+
self._emit(out, _error(msg_id, NOT_SUPPORTED, "method not offered by this view"))
|
|
68
|
+
return
|
|
69
|
+
if method == "tools/call":
|
|
70
|
+
name = (msg.get("params") or {}).get("name")
|
|
71
|
+
if name not in self.allowed:
|
|
72
|
+
self._emit(out, _error(msg_id, NOT_OFFERED, "tool not offered by this view"))
|
|
73
|
+
return
|
|
74
|
+
elif method == "tools/list":
|
|
75
|
+
self._lists.add(msg_id)
|
|
76
|
+
elif method == "initialize":
|
|
77
|
+
self._inits.add(msg_id)
|
|
78
|
+
self._send(child_in, msg)
|
|
79
|
+
|
|
80
|
+
@staticmethod
|
|
81
|
+
def _send(child_in: IO[str], msg: dict[str, Any]) -> None:
|
|
82
|
+
try:
|
|
83
|
+
child_in.write(json.dumps(msg) + "\n")
|
|
84
|
+
child_in.flush()
|
|
85
|
+
except (BrokenPipeError, ValueError, OSError):
|
|
86
|
+
pass
|
|
87
|
+
|
|
88
|
+
# -- server to client ---------------------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
def _from_server(self, line: str, child_in: IO[str], out: TextIO) -> None:
|
|
91
|
+
try:
|
|
92
|
+
msg = json.loads(line)
|
|
93
|
+
except ValueError:
|
|
94
|
+
return
|
|
95
|
+
if not isinstance(msg, dict):
|
|
96
|
+
return
|
|
97
|
+
msg_id = msg.get("id")
|
|
98
|
+
if "method" in msg:
|
|
99
|
+
if msg_id is not None: # a request of the server (sampling, roots): this view grants none
|
|
100
|
+
self._send(child_in, _error(msg_id, NOT_SUPPORTED, "not offered by this view"))
|
|
101
|
+
else:
|
|
102
|
+
self._emit(out, msg)
|
|
103
|
+
return
|
|
104
|
+
if msg_id in self._lists and isinstance(msg.get("result"), dict):
|
|
105
|
+
self._lists.discard(msg_id)
|
|
106
|
+
tools = msg["result"].get("tools")
|
|
107
|
+
if isinstance(tools, list):
|
|
108
|
+
msg["result"]["tools"] = [t for t in tools if isinstance(t, dict) and t.get("name") in self.allowed]
|
|
109
|
+
elif msg_id in self._inits and isinstance(msg.get("result"), dict):
|
|
110
|
+
self._inits.discard(msg_id)
|
|
111
|
+
caps = msg["result"].get("capabilities")
|
|
112
|
+
if isinstance(caps, dict): # only tools are offered
|
|
113
|
+
msg["result"]["capabilities"] = {k: v for k, v in caps.items() if k == "tools"}
|
|
114
|
+
self._emit(out, msg)
|
|
115
|
+
|
|
116
|
+
# -- the loop -------------------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
def run(self, stdin: TextIO, stdout: TextIO) -> int:
|
|
119
|
+
try:
|
|
120
|
+
child = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
|
121
|
+
stderr=subprocess.DEVNULL, text=True, bufsize=1)
|
|
122
|
+
except OSError:
|
|
123
|
+
return 1
|
|
124
|
+
assert child.stdin is not None and child.stdout is not None
|
|
125
|
+
|
|
126
|
+
def pump() -> None:
|
|
127
|
+
assert child.stdout is not None and child.stdin is not None
|
|
128
|
+
for line in child.stdout:
|
|
129
|
+
self._from_server(line, child.stdin, stdout)
|
|
130
|
+
|
|
131
|
+
reader = threading.Thread(target=pump, daemon=True)
|
|
132
|
+
reader.start()
|
|
133
|
+
try:
|
|
134
|
+
for line in stdin:
|
|
135
|
+
if child.poll() is not None:
|
|
136
|
+
break
|
|
137
|
+
self._from_client(line, child.stdin, stdout)
|
|
138
|
+
finally:
|
|
139
|
+
with contextlib.suppress(OSError):
|
|
140
|
+
child.stdin.close()
|
|
141
|
+
try:
|
|
142
|
+
child.wait(timeout=5)
|
|
143
|
+
except subprocess.TimeoutExpired:
|
|
144
|
+
child.terminate()
|
|
145
|
+
try:
|
|
146
|
+
child.wait(timeout=5)
|
|
147
|
+
except subprocess.TimeoutExpired:
|
|
148
|
+
child.kill()
|
|
149
|
+
reader.join(timeout=2)
|
|
150
|
+
return 0
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
INIT = {"jsonrpc": "2.0", "id": 1, "method": "initialize",
|
|
154
|
+
"params": {"protocolVersion": "2024-11-05", "capabilities": {},
|
|
155
|
+
"clientInfo": {"name": "tempergraph-check", "version": "0"}}}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def server_starts(entry: Mapping[str, Any], workdir: Path, timeout_s: float = 10.0) -> bool:
|
|
159
|
+
"""ECC-B15: True when the operator's server answers `initialize` within `timeout_s` seconds; the process is
|
|
160
|
+
stopped either way. The one place besides the proxy that starts a server of the operator's configuration."""
|
|
161
|
+
raw_env = entry.get("env")
|
|
162
|
+
env = {**os.environ, **{str(k): str(v) for k, v in raw_env.items()}} if isinstance(raw_env, dict) else dict(os.environ)
|
|
163
|
+
try:
|
|
164
|
+
proc = subprocess.Popen([str(entry["command"]), *[str(a) for a in entry.get("args") or []]],
|
|
165
|
+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
|
|
166
|
+
cwd=workdir, env=env)
|
|
167
|
+
except (OSError, ValueError):
|
|
168
|
+
return False
|
|
169
|
+
try:
|
|
170
|
+
assert proc.stdin is not None and proc.stdout is not None
|
|
171
|
+
try:
|
|
172
|
+
proc.stdin.write((json.dumps(INIT) + "\n").encode())
|
|
173
|
+
proc.stdin.flush()
|
|
174
|
+
except OSError:
|
|
175
|
+
return False
|
|
176
|
+
ready, _, _ = select.select([proc.stdout], [], [], timeout_s)
|
|
177
|
+
if not ready:
|
|
178
|
+
return False
|
|
179
|
+
try:
|
|
180
|
+
msg = json.loads(proc.stdout.readline())
|
|
181
|
+
except ValueError:
|
|
182
|
+
return False
|
|
183
|
+
return isinstance(msg, dict) and msg.get("id") == 1 and "result" in msg
|
|
184
|
+
finally:
|
|
185
|
+
with contextlib.suppress(OSError):
|
|
186
|
+
proc.kill()
|
|
187
|
+
with contextlib.suppress(Exception):
|
|
188
|
+
proc.wait(timeout=5)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def parse(argv: Sequence[str]) -> tuple[list[str], list[str]]:
|
|
192
|
+
allowed: list[str] = []
|
|
193
|
+
rest = list(argv)
|
|
194
|
+
command: list[str] = []
|
|
195
|
+
if "--" in rest:
|
|
196
|
+
i = rest.index("--")
|
|
197
|
+
command, rest = rest[i + 1:], rest[:i]
|
|
198
|
+
i = 0
|
|
199
|
+
while i < len(rest):
|
|
200
|
+
if rest[i] == "--allow" and i + 1 < len(rest):
|
|
201
|
+
allowed.append(rest[i + 1])
|
|
202
|
+
i += 2
|
|
203
|
+
else:
|
|
204
|
+
i += 1
|
|
205
|
+
return allowed, command
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
209
|
+
allowed, command = parse(sys.argv[1:] if argv is None else argv)
|
|
210
|
+
if not command:
|
|
211
|
+
return 2
|
|
212
|
+
return Proxy(allowed, command).run(sys.stdin, sys.stdout)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
if __name__ == "__main__":
|
|
216
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"""Refuse before spend (EXI-B1, EXI-B26, EXI-B27, OVR-B17).
|
|
2
|
+
|
|
3
|
+
Runs with no model call. Validation already refuses unknown executors, unbound tier aliases, unmapped
|
|
4
|
+
tools and unsupported options against the registered capability sets; the preflight adds what needs the
|
|
5
|
+
registry and the machine: each executor's probe, executor-qualified aliases against the binding table,
|
|
6
|
+
judge executor selection (EXI-B24), tool enforcement (EXI-B12) and deferred judge MCP views.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from collections.abc import Callable, Sequence
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
|
|
14
|
+
from tempergraph import executor_compat
|
|
15
|
+
from tempergraph.contracts import Deferred, JudgeSpec, ProbeReport, UnitSpec, WorkflowSpec
|
|
16
|
+
from tempergraph.executors.registry import NoJudgeExecutor, Registry, UnknownExecutor
|
|
17
|
+
from tempergraph.model.validate import Finding, validate
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(kw_only=True)
|
|
21
|
+
class PreflightReport:
|
|
22
|
+
refusals: list[Finding] = field(default_factory=list)
|
|
23
|
+
warnings: list[Finding] = field(default_factory=list)
|
|
24
|
+
authoring_warnings: list[Finding] = field(default_factory=list)
|
|
25
|
+
judges: dict[str, str] = field(default_factory=dict) # unit -> judge executor
|
|
26
|
+
step_executors: dict[str, str] = field(default_factory=dict)
|
|
27
|
+
probes: dict[str, ProbeReport] = field(default_factory=dict)
|
|
28
|
+
deferred: dict[str, list[Deferred]] = field(default_factory=dict)
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def ok(self) -> bool:
|
|
32
|
+
return not self.refusals
|
|
33
|
+
|
|
34
|
+
def first(self) -> Finding | None:
|
|
35
|
+
return self.refusals[0] if self.refusals else None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def observer_warnings(missing: Sequence[str]) -> list[Finding]:
|
|
39
|
+
"""EVT-B23: an observer the operator config names that is not installed is a warning, never a refusal."""
|
|
40
|
+
return [Finding("observer-missing", None,
|
|
41
|
+
f"observer {name!r} is named in the operator config but not installed under the "
|
|
42
|
+
"`tempergraph.observers` entry-point group; the run starts without it", "warning")
|
|
43
|
+
for name in missing]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _aliases(value: object) -> list[str]:
|
|
47
|
+
if value is None:
|
|
48
|
+
return []
|
|
49
|
+
if isinstance(value, str):
|
|
50
|
+
return [value]
|
|
51
|
+
return [str(v) for v in value] # type: ignore[attr-defined]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _slot_overrides(rep: PreflightReport, caps: dict, probe: Callable[[str, str], bool], unit: str, u: UnitSpec,
|
|
55
|
+
base: str) -> None:
|
|
56
|
+
"""CTS-B10: a slot override whose executor cannot bind its model alias or map the step's tools is refused, each with a
|
|
57
|
+
code of its own; an executor that is not registered is refused as well."""
|
|
58
|
+
assert u.contest is not None and u.step is not None and not isinstance(u.contest.slots, int)
|
|
59
|
+
for slot in u.contest.slots:
|
|
60
|
+
name = slot.executor or base
|
|
61
|
+
if name not in caps:
|
|
62
|
+
rep.refusals.append(Finding("contest-slot-executor-unknown", unit,
|
|
63
|
+
f"slot {slot.name!r} of {unit!r} names executor {name!r}, which is not registered"))
|
|
64
|
+
continue
|
|
65
|
+
if slot.executor is not None and not probe(name, unit):
|
|
66
|
+
continue
|
|
67
|
+
c = caps[name]
|
|
68
|
+
if slot.model and slot.model != "inherit":
|
|
69
|
+
alias = slot.model
|
|
70
|
+
if alias not in c.binds_aliases:
|
|
71
|
+
rep.refusals.append(Finding("contest-slot-alias-unbound", unit,
|
|
72
|
+
f"slot {slot.name!r} of {unit!r}: executor {name!r} binds no {alias!r}"))
|
|
73
|
+
for tool in u.step.tools:
|
|
74
|
+
if not c.maps(tool):
|
|
75
|
+
rep.refusals.append(Finding("contest-slot-tool-unmapped", unit,
|
|
76
|
+
f"slot {slot.name!r} of {unit!r}: executor {name!r} maps no tool for {tool!r}"))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def preflight(spec: WorkflowSpec, registry: Registry, *, judge_override: str | None = None,
|
|
80
|
+
enforce_tools: bool = False, strict_permissions: bool = False) -> PreflightReport:
|
|
81
|
+
rep = PreflightReport()
|
|
82
|
+
caps = {n: registry.get(n).capabilities() for n in registry.available()}
|
|
83
|
+
for f in validate(spec, caps):
|
|
84
|
+
if f.severity == "error":
|
|
85
|
+
rep.refusals.append(f)
|
|
86
|
+
else:
|
|
87
|
+
rep.authoring_warnings.append(f)
|
|
88
|
+
|
|
89
|
+
def probe(name: str, unit: str) -> bool:
|
|
90
|
+
if name not in rep.probes:
|
|
91
|
+
try:
|
|
92
|
+
rep.probes[name] = registry.get(name).probe()
|
|
93
|
+
except UnknownExecutor:
|
|
94
|
+
return False
|
|
95
|
+
caps[name] = registry.get(name).capabilities() # now carries the probed version
|
|
96
|
+
p = rep.probes[name]
|
|
97
|
+
untested = executor_compat.finding(name, p.version) if p.ok else None # LIF-AC4
|
|
98
|
+
if untested is not None and untested not in rep.warnings:
|
|
99
|
+
rep.warnings.append(untested)
|
|
100
|
+
if not p.ok:
|
|
101
|
+
msg = f"executor {name!r}: {p.reason}"
|
|
102
|
+
missing = p.facts.get("missing_flags") if isinstance(p.facts, dict) else None
|
|
103
|
+
if missing:
|
|
104
|
+
msg += "; this CLI lists no " + ", ".join(missing)
|
|
105
|
+
rep.refusals.append(Finding("executor-probe-failed", unit, msg))
|
|
106
|
+
return p.ok
|
|
107
|
+
|
|
108
|
+
def judge_of(unit: str, ex: str, j: JudgeSpec, tools: Sequence[str]) -> None:
|
|
109
|
+
"""The judge of a unit's gate on its own layer: its executor, its alias and the MCP views it cannot reach."""
|
|
110
|
+
try:
|
|
111
|
+
judge_ex = registry.judge_executor(ex, j.executor, judge_override)
|
|
112
|
+
except (NoJudgeExecutor, UnknownExecutor) as exc:
|
|
113
|
+
rep.refusals.append(Finding("judge-executor-none", unit, str(exc)))
|
|
114
|
+
return
|
|
115
|
+
if not probe(judge_ex, unit):
|
|
116
|
+
return
|
|
117
|
+
jc = caps[judge_ex]
|
|
118
|
+
if not (jc.restricts_judge_tools and jc.prompt_off_argv):
|
|
119
|
+
rep.refusals.append(Finding("judge-executor-unrestricted", unit,
|
|
120
|
+
f"judge executor {judge_ex!r} cannot hold a judge to read-only tools"))
|
|
121
|
+
return
|
|
122
|
+
rep.judges[unit] = judge_ex
|
|
123
|
+
if j.model and j.model not in jc.binds_aliases:
|
|
124
|
+
rep.refusals.append(Finding("alias-unbound", unit, f"judge executor {judge_ex!r} binds no {j.model!r}"))
|
|
125
|
+
mcp = [t for t in tools if t.startswith("mcp:")]
|
|
126
|
+
if mcp and not jc.judge_mcp:
|
|
127
|
+
rep.deferred[unit] = [Deferred(capability=t, reason="judge_mcp") for t in mcp]
|
|
128
|
+
rep.warnings.append(Finding("judge-view-deferred", unit,
|
|
129
|
+
f"judge views of {', '.join(mcp)} are out of reach on {judge_ex!r}",
|
|
130
|
+
"warning"))
|
|
131
|
+
|
|
132
|
+
def council(unit: str, u: UnitSpec) -> None:
|
|
133
|
+
"""CNL-B6: each member's alias and tools are checked against its own executor (validation reports a tool the
|
|
134
|
+
executor maps no name for, this adds the probe, the binding table and enforcement), the chair on its own layer
|
|
135
|
+
and the judge on the gate's; a gap is a refusal, and the run starts nothing."""
|
|
136
|
+
c = u.council
|
|
137
|
+
assert c is not None
|
|
138
|
+
sessions = [(f"member {m.name!r}", f"{unit}.member:{m.name}", m.executor, m.model, m.tools) for m in c.members]
|
|
139
|
+
if c.chair is not None:
|
|
140
|
+
sessions.append(("the chair", f"{unit}.chair", c.chair.executor, c.chair.model, ()))
|
|
141
|
+
for who, key, named, alias, tools in sessions:
|
|
142
|
+
ex = named or spec.default_executor
|
|
143
|
+
rep.step_executors[key] = ex
|
|
144
|
+
if ex not in caps or not probe(ex, unit):
|
|
145
|
+
continue
|
|
146
|
+
cap = caps[ex]
|
|
147
|
+
if alias and alias.startswith(ex + ":") and alias not in cap.binds_aliases:
|
|
148
|
+
rep.refusals.append(Finding("alias-unbound", unit, f"{who}: the binding table has no {alias!r}"))
|
|
149
|
+
if tools and (enforce_tools or strict_permissions) and not cap.enforces_step_tools:
|
|
150
|
+
rep.refusals.append(Finding("enforcement-unsupported", unit,
|
|
151
|
+
f"{who}: executor {ex!r} cannot enforce the member's declared tools"))
|
|
152
|
+
if u.gate.judge is not None:
|
|
153
|
+
judge_of(unit, spec.default_executor, u.gate.judge, ())
|
|
154
|
+
|
|
155
|
+
for unit in spec.order:
|
|
156
|
+
u = spec.units[unit]
|
|
157
|
+
st = u.step
|
|
158
|
+
if u.kind == "council" and u.council is not None:
|
|
159
|
+
council(unit, u)
|
|
160
|
+
continue
|
|
161
|
+
if u.kind not in ("step", "map", "contest") or st is None:
|
|
162
|
+
continue
|
|
163
|
+
ex = st.executor or spec.default_executor
|
|
164
|
+
rep.step_executors[unit] = ex
|
|
165
|
+
if u.contest is not None and not isinstance(u.contest.slots, int):
|
|
166
|
+
_slot_overrides(rep, caps, probe, unit, u, ex) # CTS-B10: each slot's own executor and model
|
|
167
|
+
if ex not in caps or not probe(ex, unit):
|
|
168
|
+
continue
|
|
169
|
+
c = caps[ex]
|
|
170
|
+
for alias in _aliases(st.model) + _aliases(spec.model_profile.get(unit)):
|
|
171
|
+
if alias.startswith(ex + ":") and alias not in c.binds_aliases:
|
|
172
|
+
rep.refusals.append(Finding("alias-unbound", unit, f"the binding table has no {alias!r}"))
|
|
173
|
+
if (enforce_tools or strict_permissions) and not c.enforces_step_tools:
|
|
174
|
+
rep.refusals.append(Finding("enforcement-unsupported", unit,
|
|
175
|
+
f"executor {ex!r} cannot enforce the step's declared tools"))
|
|
176
|
+
if any(t.startswith("skill:") for t in st.tools) and not c.hosts_authoring_surface:
|
|
177
|
+
rep.warnings.append(Finding("authoring-surface-missing", unit,
|
|
178
|
+
f"executor {ex!r} loads no skills", "warning"))
|
|
179
|
+
undefined_of = getattr(registry.get(ex), "undefined_mcp_servers", None) # optional, as `unreachable_views`
|
|
180
|
+
if undefined_of is not None:
|
|
181
|
+
missing_servers = undefined_of(tuple(st.tools))
|
|
182
|
+
if missing_servers:
|
|
183
|
+
rep.refusals.append(Finding("mcp-server-undefined", unit,
|
|
184
|
+
f"step {unit!r} declares MCP server(s) {', '.join(missing_servers)} that "
|
|
185
|
+
"the operator's own MCP configuration does not define; define them there "
|
|
186
|
+
"(a repository `.mcp.json` does not count)"))
|
|
187
|
+
for _owned in c.launcher_owned_paths: # EXI-B30: a declared path must not cover a tracked or pre-existing file
|
|
188
|
+
rep.warnings.append(Finding("launcher-owned-path", unit,
|
|
189
|
+
f"executor {ex!r} declares launcher_owned_paths={c.launcher_owned_paths!r}; "
|
|
190
|
+
"preflight cannot check tracked files without a workspace — "
|
|
191
|
+
"the guard will exclude these paths from fingerprints",
|
|
192
|
+
"warning"))
|
|
193
|
+
break # one warning per unit is enough
|
|
194
|
+
if u.gate.judge is not None:
|
|
195
|
+
judge_of(unit, ex, u.gate.judge, st.tools)
|
|
196
|
+
return rep
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""The executor registry and judge executor selection (EXI-B16, EXI-B17, EXI-B24).
|
|
2
|
+
|
|
3
|
+
Names are constants registered in a fixed order; workflow data selects one by name and never supplies a
|
|
4
|
+
path or a command. Release 1 registers ``claude`` only (ADR `first-release-ships-the-claude-executor-only`). Tests build their own `Registry`
|
|
5
|
+
holding stand-ins.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from tempergraph.constants import EXECUTOR_NAMES
|
|
11
|
+
from tempergraph.contracts import Executor
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class UnknownExecutor(LookupError):
|
|
15
|
+
def __init__(self, name: str) -> None:
|
|
16
|
+
super().__init__(f"unknown executor {name!r}")
|
|
17
|
+
self.name = name
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class NoJudgeExecutor(LookupError):
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Registry:
|
|
25
|
+
def __init__(self) -> None:
|
|
26
|
+
self._items: dict[str, Executor] = {}
|
|
27
|
+
|
|
28
|
+
def register(self, executor: Executor) -> None:
|
|
29
|
+
if executor.name not in EXECUTOR_NAMES:
|
|
30
|
+
raise ValueError(f"executor name {executor.name!r} is not a registered constant")
|
|
31
|
+
self._items[executor.name] = executor
|
|
32
|
+
|
|
33
|
+
def get(self, name: str) -> Executor:
|
|
34
|
+
if name not in self._items:
|
|
35
|
+
raise UnknownExecutor(name)
|
|
36
|
+
return self._items[name]
|
|
37
|
+
|
|
38
|
+
def available(self) -> list[str]:
|
|
39
|
+
"""Registered names in the constant registration order."""
|
|
40
|
+
return [n for n in EXECUTOR_NAMES if n in self._items]
|
|
41
|
+
|
|
42
|
+
def judge_executor(self, step_executor: str, gate_judge_executor: str | None,
|
|
43
|
+
operator_override: str | None, designated: str | None = None) -> str:
|
|
44
|
+
"""EXI-B24 order: override, the gate's, the step's if it restricts judge tools, the designated,
|
|
45
|
+
else the first registered executor that declares it."""
|
|
46
|
+
for name in (operator_override, gate_judge_executor):
|
|
47
|
+
if name:
|
|
48
|
+
self.get(name)
|
|
49
|
+
return name
|
|
50
|
+
if step_executor in self._items and _can_judge(self._items[step_executor]):
|
|
51
|
+
return step_executor
|
|
52
|
+
if designated and designated in self._items and _can_judge(self._items[designated]):
|
|
53
|
+
return designated
|
|
54
|
+
for name in self.available():
|
|
55
|
+
if _can_judge(self._items[name]):
|
|
56
|
+
return name
|
|
57
|
+
raise NoJudgeExecutor(f"no registered executor can hold a judge to read-only tools (step on {step_executor})")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _can_judge(ex: Executor) -> bool:
|
|
61
|
+
caps = ex.capabilities()
|
|
62
|
+
return caps.restricts_judge_tools and caps.prompt_off_argv
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def default_registry() -> Registry:
|
|
66
|
+
"""The shipped registry: `claude` only in release 1 (ADR `first-release-ships-the-claude-executor-only`)."""
|
|
67
|
+
from tempergraph.executors.claude import ClaudeExecutor
|
|
68
|
+
|
|
69
|
+
reg = Registry()
|
|
70
|
+
reg.register(ClaudeExecutor())
|
|
71
|
+
return reg
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""A registry holding one scripted stand-in, for the engine's own model-free runs (the generated stand-in run
|
|
2
|
+
of a scaffolded package, SCF-B14, SCF-B15, SCF-B16, SCF-B17). Engine code outside this package reaches the stand-ins only here."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from collections.abc import Sequence
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from tempergraph.executors.registry import Registry
|
|
10
|
+
from tempergraph.executors.standins import answer, standin
|
|
11
|
+
|
|
12
|
+
__all__ = ["answer", "scripted_registry"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def scripted_registry(name: str, steps: Sequence[Any], judges: Sequence[Any]) -> Registry:
|
|
16
|
+
r = Registry()
|
|
17
|
+
r.register(standin(name, steps=list(steps), judges=list(judges))) # type: ignore[arg-type]
|
|
18
|
+
return r
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""Turn a launcher outcome into a `SessionResult` (EXI-B6, EXI-B7, SSN-B1 to SSN-B6).
|
|
2
|
+
|
|
3
|
+
The shared part: tool calls in order, denied names, tools at start, the share of wall time inside tool
|
|
4
|
+
calls, usage from the `result` event only (never 0 when unknown), and the process-level infra causes.
|
|
5
|
+
Each executor adds its own result-level classification, read from structured facts only.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import errno
|
|
11
|
+
import signal
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
from tempergraph.contracts import ErrorKind, Event, InfraCause, SessionResult, ToolCall, Usage
|
|
16
|
+
from tempergraph.executors.launcher import RawOutcome
|
|
17
|
+
|
|
18
|
+
RESOURCE_ERRNOS = frozenset({errno.EAGAIN, errno.ENOMEM, errno.EMFILE, errno.ENFILE})
|
|
19
|
+
KILLED_BY_OS = (-signal.SIGKILL, 137) if hasattr(signal, "SIGKILL") else ()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True, kw_only=True)
|
|
23
|
+
class Summary:
|
|
24
|
+
tool_calls: list[ToolCall]
|
|
25
|
+
denied: tuple[str, ...]
|
|
26
|
+
tools_at_start: tuple[str, ...]
|
|
27
|
+
session_id: str | None
|
|
28
|
+
model: str | None
|
|
29
|
+
result: dict[str, Any] | None
|
|
30
|
+
retry_categories: tuple[str, ...]
|
|
31
|
+
tool_wall_share: float
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def summarize(events: list[Event], duration_s: float) -> Summary:
|
|
35
|
+
calls: list[ToolCall] = []
|
|
36
|
+
index: dict[str, int] = {}
|
|
37
|
+
started: dict[str, float] = {}
|
|
38
|
+
in_tools = 0.0
|
|
39
|
+
denied: list[str] = []
|
|
40
|
+
tools: tuple[str, ...] = ()
|
|
41
|
+
session_id = model = None
|
|
42
|
+
result: dict[str, Any] | None = None
|
|
43
|
+
retries: list[str] = []
|
|
44
|
+
for ev in events:
|
|
45
|
+
d = ev.data
|
|
46
|
+
if ev.kind == "session_started":
|
|
47
|
+
tools = tuple(d.get("tools") or ())
|
|
48
|
+
session_id = d.get("session_id") or session_id
|
|
49
|
+
model = d.get("model") or model
|
|
50
|
+
elif ev.kind == "tool_started":
|
|
51
|
+
cid = str(d.get("call_id", ""))
|
|
52
|
+
index[cid] = len(calls)
|
|
53
|
+
started[cid] = ev.ts
|
|
54
|
+
calls.append(ToolCall(name=str(d.get("name", "")), subagent=bool(d.get("subagent")), call_id=cid))
|
|
55
|
+
elif ev.kind == "tool_finished":
|
|
56
|
+
cid = str(d.get("call_id", ""))
|
|
57
|
+
if cid in index:
|
|
58
|
+
c = calls[index[cid]]
|
|
59
|
+
calls[index[cid]] = ToolCall(name=c.name, ok=bool(d.get("ok")), subagent=c.subagent, call_id=cid)
|
|
60
|
+
if cid in started:
|
|
61
|
+
in_tools += max(0.0, ev.ts - started.pop(cid))
|
|
62
|
+
elif ev.kind == "denied":
|
|
63
|
+
denied.append(str(d.get("name", "")))
|
|
64
|
+
elif ev.kind == "retrying":
|
|
65
|
+
retries.append(str(d.get("category") or ""))
|
|
66
|
+
elif ev.kind == "result":
|
|
67
|
+
result = dict(d)
|
|
68
|
+
session_id = d.get("session_id") or session_id
|
|
69
|
+
share = min(1.0, in_tools / duration_s) if duration_s > 0 else 0.0
|
|
70
|
+
return Summary(tool_calls=calls, denied=tuple(denied), tools_at_start=tools, session_id=session_id,
|
|
71
|
+
model=model, result=result, retry_categories=tuple(retries), tool_wall_share=share)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def process_cause(raw: RawOutcome) -> InfraCause | None:
|
|
75
|
+
"""Causes visible before any stream is read: spawn, stdin, an empty or OS-killed process."""
|
|
76
|
+
if raw.spawn_error is not None:
|
|
77
|
+
return InfraCause.SPAWN_FAILED
|
|
78
|
+
if raw.prompt_timeout:
|
|
79
|
+
return InfraCause.PROMPT_NOT_DELIVERED
|
|
80
|
+
if raw.broken_pipe:
|
|
81
|
+
return InfraCause.BROKEN_PIPE
|
|
82
|
+
if raw.lines == 0 and raw.stop_reason is None:
|
|
83
|
+
return InfraCause.NO_OUTPUT
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def build_result(raw: RawOutcome, s: Summary, *, cli_version: str, argv: list[str], applied: tuple[str, ...],
|
|
88
|
+
infra: InfraCause | None, error_kind: ErrorKind | None, ok: bool, usage_limit: bool = False,
|
|
89
|
+
usage_limit_resets_at: float | None = None) -> SessionResult:
|
|
90
|
+
usage = s.result.get("usage") if s.result else None
|
|
91
|
+
text = str(s.result.get("text") or "") if s.result else ""
|
|
92
|
+
timed_out = raw.stop_reason == "timeout"
|
|
93
|
+
stalled = raw.stop_reason == "idle"
|
|
94
|
+
partial = raw.stop_reason is not None and (raw.killed or s.result is None)
|
|
95
|
+
built_ok = ok and infra is None and error_kind is None and not (timed_out or stalled or partial)
|
|
96
|
+
return SessionResult(
|
|
97
|
+
ok=built_ok, usage_limit=usage_limit and not built_ok, # SSN-B11: never true for an ok session
|
|
98
|
+
usage_limit_resets_at=usage_limit_resets_at if usage_limit and not built_ok else None,
|
|
99
|
+
text=text, session_id=s.session_id, usage=usage if isinstance(usage, Usage) else Usage(),
|
|
100
|
+
tool_calls=s.tool_calls, timed_out=timed_out, stalled=stalled, partial=partial, infra_cause=infra,
|
|
101
|
+
error_kind=error_kind, applied_options=applied, cli_version=cli_version, model=s.model, denied=s.denied,
|
|
102
|
+
tools_at_start=s.tools_at_start, tool_wall_share=s.tool_wall_share, prompt_gap_s=raw.prompt_gap_s,
|
|
103
|
+
duration_s=raw.duration_s, argv=tuple(argv))
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def killed_by_os(raw: RawOutcome) -> bool:
|
|
107
|
+
return raw.stop_reason is None and raw.exit_code in KILLED_BY_OS
|