techtree 0.1.0__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.
- techtree/__init__.py +35 -0
- techtree/__main__.py +14 -0
- techtree/canonical.py +239 -0
- techtree/catalog/__init__.py +25 -0
- techtree/catalog/repository.py +400 -0
- techtree/catalog/service.py +419 -0
- techtree/cli/__init__.py +1 -0
- techtree/cli/app.py +416 -0
- techtree/cli/commands/__init__.py +1 -0
- techtree/cli/commands/climb.py +1223 -0
- techtree/cli/commands/doctor.py +147 -0
- techtree/cli/commands/engine.py +207 -0
- techtree/cli/commands/proof.py +556 -0
- techtree/cli/commands/publish.py +447 -0
- techtree/cli/commands/release.py +303 -0
- techtree/cli/commands/run.py +1067 -0
- techtree/cli/commands/setup.py +181 -0
- techtree/cli/commands/skill.py +221 -0
- techtree/cli/commands/uplift.py +698 -0
- techtree/cli/commands/withdraw.py +212 -0
- techtree/cli/confirm.py +47 -0
- techtree/cli/context.py +96 -0
- techtree/cli/invoke.py +220 -0
- techtree/cli/output.py +280 -0
- techtree/constants.py +138 -0
- techtree/crypto.py +128 -0
- techtree/doctor/__init__.py +1 -0
- techtree/doctor/checks.py +675 -0
- techtree/doctor/execution_checks.py +435 -0
- techtree/doctor/service.py +326 -0
- techtree/drafts/__init__.py +32 -0
- techtree/drafts/source.py +146 -0
- techtree/drafts/store.py +992 -0
- techtree/engines/__init__.py +1 -0
- techtree/engines/bundle.py +251 -0
- techtree/engines/installer.py +679 -0
- techtree/engines/registry.py +235 -0
- techtree/engines/runner.py +170 -0
- techtree/errors.py +262 -0
- techtree/fs.py +234 -0
- techtree/harness.py +108 -0
- techtree/identity/__init__.py +41 -0
- techtree/identity/models.py +113 -0
- techtree/identity/service.py +199 -0
- techtree/identity/store.py +263 -0
- techtree/ids.py +85 -0
- techtree/manifests/__init__.py +39 -0
- techtree/manifests/builder.py +433 -0
- techtree/manifests/compare.py +376 -0
- techtree/models/__init__.py +282 -0
- techtree/models/base.py +201 -0
- techtree/models/campaign.py +484 -0
- techtree/models/catalog.py +227 -0
- techtree/models/cli.py +151 -0
- techtree/models/climb.py +254 -0
- techtree/models/data_policy.py +130 -0
- techtree/models/engine.py +156 -0
- techtree/models/episode_receipt.py +130 -0
- techtree/models/evaluation_backend.py +113 -0
- techtree/models/experiment.py +154 -0
- techtree/models/run.py +214 -0
- techtree/models/skill.py +156 -0
- techtree/models/uplift_report.py +158 -0
- techtree/models/validation.py +299 -0
- techtree/paths.py +116 -0
- techtree/presentation/__init__.py +31 -0
- techtree/presentation/build.py +1242 -0
- techtree/presentation/compact.py +246 -0
- techtree/presentation/evidence.py +169 -0
- techtree/presentation/models.py +358 -0
- techtree/presentation/rich.py +312 -0
- techtree/presentation/sanitize.py +156 -0
- techtree/publication/__init__.py +44 -0
- techtree/publication/address.py +180 -0
- techtree/publication/coordinates.py +26 -0
- techtree/publication/journal.py +212 -0
- techtree/publication/keccak.py +183 -0
- techtree/publication/models.py +209 -0
- techtree/publication/offer.py +35 -0
- techtree/publication/service.py +618 -0
- techtree/publication/transport.py +296 -0
- techtree/publication/verify.py +242 -0
- techtree/publication/withdraw.py +156 -0
- techtree/py.typed +0 -0
- techtree/receipts/__init__.py +52 -0
- techtree/receipts/bundle.py +578 -0
- techtree/receipts/compare.py +1065 -0
- techtree/receipts/episode.py +672 -0
- techtree/receipts/execution.py +630 -0
- techtree/receipts/observed.py +474 -0
- techtree/receipts/set.py +336 -0
- techtree/receipts/uplift.py +655 -0
- techtree/receipts/verify.py +1055 -0
- techtree/release/__init__.py +9 -0
- techtree/release/bootstrap.py +509 -0
- techtree/release/checks.py +376 -0
- techtree/release/document.py +125 -0
- techtree/release/generate.py +221 -0
- techtree/release/models.py +293 -0
- techtree/release/provenance.py +109 -0
- techtree/resources/catalog/campaigns/hello-world-climb.json +1 -0
- techtree/resources/catalog/catalog.json +32 -0
- techtree/resources/catalog/climbs/hello-world-climb.json +1 -0
- techtree/resources/catalog/data-policies/hello-world-climb.json +1 -0
- techtree/resources/catalog/taskset-validations/hello-world-climb.json +1 -0
- techtree/resources/catalog/validation-evidence/hello-world-climb.json +1 -0
- techtree/resources/engines/default/engine.json +20 -0
- techtree/resources/engines/default/packages/procedure-transfer-v1/procedure_transfer_v1/__init__.py +7 -0
- techtree/resources/engines/default/packages/procedure-transfer-v1/procedure_transfer_v1/algorithm.py +136 -0
- techtree/resources/engines/default/packages/procedure-transfer-v1/procedure_transfer_v1/dataset.py +156 -0
- techtree/resources/engines/default/packages/procedure-transfer-v1/procedure_transfer_v1/env.py +48 -0
- techtree/resources/engines/default/packages/procedure-transfer-v1/procedure_transfer_v1/taskset.py +163 -0
- techtree/resources/engines/default/packages/procedure-transfer-v1/pyproject.toml +13 -0
- techtree/resources/engines/default/pyproject.toml +23 -0
- techtree/resources/engines/default/tools/inspect_taskset.py +124 -0
- techtree/resources/engines/default/tools/normalize_eval_output.py +470 -0
- techtree/resources/engines/default/tools/normalize_validation.py +222 -0
- techtree/resources/engines/default/uv.lock +1758 -0
- techtree/resources/harness/hermes-agent-0.19.0.json +69 -0
- techtree/resources/release/build-provenance.json +4 -0
- techtree/resources/release/release-core.json +24 -0
- techtree/runs/__init__.py +31 -0
- techtree/runs/artifacts.py +750 -0
- techtree/runs/child_registry.py +228 -0
- techtree/runs/events.py +478 -0
- techtree/runs/executor.py +140 -0
- techtree/runs/fake.py +741 -0
- techtree/runs/launcher.py +253 -0
- techtree/runs/machine.py +489 -0
- techtree/runs/real.py +789 -0
- techtree/runs/service.py +616 -0
- techtree/runs/store.py +555 -0
- techtree/runs/validation.py +259 -0
- techtree/runs/variants.py +684 -0
- techtree/settings.py +143 -0
- techtree/skills/__init__.py +14 -0
- techtree/skills/archive.py +282 -0
- techtree/skills/policy.py +62 -0
- techtree/skills/scanner.py +394 -0
- techtree/skills/service.py +752 -0
- techtree/skills/starter.py +434 -0
- techtree/tasksets/__init__.py +1 -0
- techtree/tasksets/membership.py +269 -0
- techtree/tasksets/provider.py +207 -0
- techtree/tasksets/resolver.py +311 -0
- techtree/tasksets/service.py +484 -0
- techtree/tasksets/verifiers_cli.py +538 -0
- techtree/uplift/__init__.py +20 -0
- techtree/uplift/context.py +544 -0
- techtree/uplift/derive.py +203 -0
- techtree/uplift/public_tasks.py +151 -0
- techtree/uplift/service.py +719 -0
- techtree/uplift/source.py +160 -0
- techtree/verifiers/__init__.py +31 -0
- techtree/verifiers/budget.py +219 -0
- techtree/verifiers/child.py +633 -0
- techtree/verifiers/compiler.py +432 -0
- techtree/verifiers/config.py +365 -0
- techtree/verifiers/credentials.py +321 -0
- techtree/verifiers/image.py +126 -0
- techtree/verifiers/models.py +527 -0
- techtree/verifiers/outputs.py +368 -0
- techtree/verifiers/progress.py +192 -0
- techtree/verifiers/supervisor.py +341 -0
- techtree/verifiers/verify.py +782 -0
- techtree/version.py +39 -0
- techtree/worker/__init__.py +18 -0
- techtree/worker/execute.py +487 -0
- techtree/worker/main.py +57 -0
- techtree-0.1.0.dist-info/METADATA +344 -0
- techtree-0.1.0.dist-info/RECORD +174 -0
- techtree-0.1.0.dist-info/WHEEL +4 -0
- techtree-0.1.0.dist-info/entry_points.txt +3 -0
- techtree-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
"""One function per thing that can be wrong with a host. Spec section 13.1.
|
|
2
|
+
|
|
3
|
+
Each check answers a single question and returns a :class:`~techtree.models.
|
|
4
|
+
cli.DoctorCheck` whether the answer is good or bad. No check raises: a Doctor
|
|
5
|
+
that stops at the first problem tells you about one problem, and the point of
|
|
6
|
+
Doctor is to tell you about all of them at once.
|
|
7
|
+
|
|
8
|
+
``blocking`` is a claim about *this* moment, not about the tool in general.
|
|
9
|
+
Python and a usable Techtree home block everything, so a failure there blocks.
|
|
10
|
+
uv blocks engine setup and nothing else, so an ordinary Doctor reports it as a
|
|
11
|
+
warning and says what it will block. Docker is a warning before the subject
|
|
12
|
+
work package exists.
|
|
13
|
+
|
|
14
|
+
Two checks here are about the host agent rather than about Techtree, and
|
|
15
|
+
neither is ever a fault. Hermes is where a person's agent drives Techtree from,
|
|
16
|
+
and the Techtree plugin is what puts Techtree's commands in front of that
|
|
17
|
+
agent; a machine with neither still runs every command in this program. So
|
|
18
|
+
both are observations with a next step attached, and the one thing they must
|
|
19
|
+
never do is turn a ready host into an unready one.
|
|
20
|
+
|
|
21
|
+
Two platform strings appear here and they are different things. The *host*
|
|
22
|
+
platform is where Techtree itself runs. The *Docker* platform is where an
|
|
23
|
+
evaluated subject would run, reported by the daemon, and frequently not the
|
|
24
|
+
same machine. Both use the one ``<os>/<arch>`` vocabulary so they can be
|
|
25
|
+
compared, and Doctor shows both rather than implying one from the other.
|
|
26
|
+
|
|
27
|
+
Every external tool is invoked as an argument vector with a timeout and with
|
|
28
|
+
stdin closed. No shell is involved, so nothing here can be influenced by what a
|
|
29
|
+
directory happens to be called, and no probe can block on a prompt.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
from __future__ import annotations
|
|
33
|
+
|
|
34
|
+
import json
|
|
35
|
+
import os
|
|
36
|
+
import platform
|
|
37
|
+
import shutil
|
|
38
|
+
import stat
|
|
39
|
+
import subprocess
|
|
40
|
+
import sys
|
|
41
|
+
import tempfile
|
|
42
|
+
from dataclasses import dataclass
|
|
43
|
+
from typing import Final
|
|
44
|
+
|
|
45
|
+
from techtree.engines.registry import EngineRegistry
|
|
46
|
+
from techtree.errors import PrerequisiteError
|
|
47
|
+
from techtree.models.base import JsonValue
|
|
48
|
+
from techtree.models.catalog import EngineCompatibilityStatus
|
|
49
|
+
from techtree.models.cli import CheckStatus, DoctorCheck
|
|
50
|
+
from techtree.models.engine import normalize_host_platform
|
|
51
|
+
from techtree.paths import TechtreePaths
|
|
52
|
+
from techtree.settings import Settings
|
|
53
|
+
|
|
54
|
+
__all__ = [
|
|
55
|
+
"DAEMON_TIMEOUT_SECONDS",
|
|
56
|
+
"START_PAGE_URL",
|
|
57
|
+
"SUPPORTED_PYTHON",
|
|
58
|
+
"TECHTREE_PLUGIN_NAME",
|
|
59
|
+
"VERSION_TIMEOUT_SECONDS",
|
|
60
|
+
"check_active_engine",
|
|
61
|
+
"check_docker_cli",
|
|
62
|
+
"check_docker_daemon",
|
|
63
|
+
"check_hermes_cli",
|
|
64
|
+
"check_hermes_plugin",
|
|
65
|
+
"check_host_platform",
|
|
66
|
+
"check_python_version",
|
|
67
|
+
"check_techtree_home",
|
|
68
|
+
"check_uv_cli",
|
|
69
|
+
"detect_host_platform",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
#: Asking a tool for its version is a local operation. Anything slower than
|
|
73
|
+
#: this is a broken installation, not a slow one.
|
|
74
|
+
VERSION_TIMEOUT_SECONDS: Final = 10.0
|
|
75
|
+
#: Reaching the Docker daemon can involve starting a VM on macOS, so it gets
|
|
76
|
+
#: more room than a version probe.
|
|
77
|
+
DAEMON_TIMEOUT_SECONDS: Final = 20.0
|
|
78
|
+
|
|
79
|
+
#: The interpreter range the project declares. Kept as a pair of tuples so the
|
|
80
|
+
#: comparison is on version numbers rather than on strings.
|
|
81
|
+
SUPPORTED_PYTHON: Final[tuple[tuple[int, int], tuple[int, int]]] = ((3, 12), (3, 14))
|
|
82
|
+
|
|
83
|
+
#: Techtree state is single-user. Anything more permissive is worth saying out
|
|
84
|
+
#: loud without refusing to work.
|
|
85
|
+
_PRIVATE_DIRECTORY_MODE: Final = 0o700
|
|
86
|
+
|
|
87
|
+
#: The name the Techtree plugin registers with Hermes, and what Doctor looks
|
|
88
|
+
#: for in a plugin listing.
|
|
89
|
+
TECHTREE_PLUGIN_NAME: Final = "techtree"
|
|
90
|
+
|
|
91
|
+
#: The word Hermes writes beside a plugin it will actually load.
|
|
92
|
+
_ENABLED: Final = "enabled"
|
|
93
|
+
|
|
94
|
+
#: The two words Hermes writes beside a plugin it will not load: one nobody has
|
|
95
|
+
#: turned on, and one somebody turned off. Techtree's answer is the same for
|
|
96
|
+
#: both, because from where a person sits they are the same situation.
|
|
97
|
+
_NOT_ENABLED: Final[frozenset[str]] = frozenset({"not enabled", "disabled"})
|
|
98
|
+
|
|
99
|
+
#: Decision 0024 section 4: the pinned installation guide for this release.
|
|
100
|
+
#:
|
|
101
|
+
#: Doctor points at it instead of printing the plugin's install command, and
|
|
102
|
+
#: the reason is an ordering fact rather than a shortcut. Decision 0026 makes
|
|
103
|
+
#: the release contract a document that is authored first and describes only
|
|
104
|
+
#: what is knowable at that moment; the plugin then embeds a byte-identical
|
|
105
|
+
#: copy of that contract, and the website's release document names the commit
|
|
106
|
+
#: the plugin ended up at. A commit that comes into existence two steps after
|
|
107
|
+
#: the contract cannot be a field of the contract, so this program has no way
|
|
108
|
+
#: to know it — and a coordinate invented here would be worse than an address
|
|
109
|
+
#: that is always current.
|
|
110
|
+
START_PAGE_URL: Final = "https://techtree.sh/start"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@dataclass(frozen=True)
|
|
114
|
+
class _Probe:
|
|
115
|
+
"""What running one external tool told us.
|
|
116
|
+
|
|
117
|
+
``output`` is the one line a version probe is after. ``stdout`` is
|
|
118
|
+
everything the tool wrote, which is what a machine-readable answer needs.
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
executable: str | None
|
|
122
|
+
exit_code: int | None
|
|
123
|
+
output: str
|
|
124
|
+
stdout: str
|
|
125
|
+
timed_out: bool
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def found(self) -> bool:
|
|
129
|
+
"""Whether the executable exists on PATH at all."""
|
|
130
|
+
return self.executable is not None
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def succeeded(self) -> bool:
|
|
134
|
+
"""Whether the tool ran and reported success."""
|
|
135
|
+
return self.exit_code == 0
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _probe(argv: list[str], *, timeout: float) -> _Probe:
|
|
139
|
+
"""Run one argument vector with stdin closed and a hard timeout."""
|
|
140
|
+
executable = shutil.which(argv[0])
|
|
141
|
+
if executable is None:
|
|
142
|
+
return _Probe(
|
|
143
|
+
executable=None, exit_code=None, output="", stdout="", timed_out=False
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
try:
|
|
147
|
+
completed = subprocess.run(
|
|
148
|
+
[executable, *argv[1:]],
|
|
149
|
+
capture_output=True,
|
|
150
|
+
text=True,
|
|
151
|
+
timeout=timeout,
|
|
152
|
+
check=False,
|
|
153
|
+
stdin=subprocess.DEVNULL,
|
|
154
|
+
)
|
|
155
|
+
except subprocess.TimeoutExpired:
|
|
156
|
+
return _Probe(
|
|
157
|
+
executable=executable,
|
|
158
|
+
exit_code=None,
|
|
159
|
+
output="",
|
|
160
|
+
stdout="",
|
|
161
|
+
timed_out=True,
|
|
162
|
+
)
|
|
163
|
+
except OSError as error:
|
|
164
|
+
return _Probe(
|
|
165
|
+
executable=executable,
|
|
166
|
+
exit_code=None,
|
|
167
|
+
output=str(error.strerror or error),
|
|
168
|
+
stdout="",
|
|
169
|
+
timed_out=False,
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
return _Probe(
|
|
173
|
+
executable=executable,
|
|
174
|
+
exit_code=completed.returncode,
|
|
175
|
+
output=_first_line(completed.stdout) or _first_line(completed.stderr),
|
|
176
|
+
stdout=completed.stdout,
|
|
177
|
+
timed_out=False,
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def _first_line(text: str) -> str:
|
|
182
|
+
"""Return the first non-blank line, which is where tools put the answer."""
|
|
183
|
+
for line in text.splitlines():
|
|
184
|
+
stripped = line.strip()
|
|
185
|
+
if stripped:
|
|
186
|
+
return stripped
|
|
187
|
+
return ""
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def detect_host_platform() -> str | None:
|
|
191
|
+
"""Return the normalized ``<os>/<arch>`` host name, or None if unsupported."""
|
|
192
|
+
try:
|
|
193
|
+
return normalize_host_platform(sys.platform, platform.machine())
|
|
194
|
+
except PrerequisiteError:
|
|
195
|
+
return None
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def check_python_version() -> DoctorCheck:
|
|
199
|
+
"""Require Python >=3.12,<3.14."""
|
|
200
|
+
version = platform.python_version()
|
|
201
|
+
minimum, exclusive_maximum = SUPPORTED_PYTHON
|
|
202
|
+
running = sys.version_info[:2]
|
|
203
|
+
supported = minimum <= running < exclusive_maximum
|
|
204
|
+
|
|
205
|
+
if supported:
|
|
206
|
+
detail = f"Python {version}"
|
|
207
|
+
else:
|
|
208
|
+
detail = (
|
|
209
|
+
f"Python {version} is outside the supported range "
|
|
210
|
+
f">={minimum[0]}.{minimum[1]},"
|
|
211
|
+
f"<{exclusive_maximum[0]}.{exclusive_maximum[1]}"
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
return DoctorCheck(
|
|
215
|
+
id="python_version",
|
|
216
|
+
label="Python version",
|
|
217
|
+
status=CheckStatus.PASS if supported else CheckStatus.FAIL,
|
|
218
|
+
detail=detail,
|
|
219
|
+
blocking=not supported,
|
|
220
|
+
metadata={"python_version": version, "executable": sys.executable},
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def check_host_platform(host_platform: str | None) -> DoctorCheck:
|
|
225
|
+
"""Report the normalized host platform Techtree is running on."""
|
|
226
|
+
if host_platform is None:
|
|
227
|
+
return DoctorCheck(
|
|
228
|
+
id="host_platform",
|
|
229
|
+
label="Host platform",
|
|
230
|
+
status=CheckStatus.FAIL,
|
|
231
|
+
detail=(
|
|
232
|
+
f"{sys.platform}/{platform.machine()} is not a supported host; "
|
|
233
|
+
"Techtree supports darwin and linux on arm64 and amd64"
|
|
234
|
+
),
|
|
235
|
+
blocking=True,
|
|
236
|
+
metadata={"sys_platform": sys.platform, "machine": platform.machine()},
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
return DoctorCheck(
|
|
240
|
+
id="host_platform",
|
|
241
|
+
label="Host platform",
|
|
242
|
+
status=CheckStatus.PASS,
|
|
243
|
+
detail=host_platform,
|
|
244
|
+
blocking=False,
|
|
245
|
+
metadata={"host_platform": host_platform},
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def check_techtree_home(paths: TechtreePaths) -> DoctorCheck:
|
|
250
|
+
"""Check creation, writeability, and private permissions."""
|
|
251
|
+
root = paths.root
|
|
252
|
+
metadata: dict[str, JsonValue] = {"path": str(root)}
|
|
253
|
+
|
|
254
|
+
if not root.is_dir():
|
|
255
|
+
return DoctorCheck(
|
|
256
|
+
id="techtree_home",
|
|
257
|
+
label="Techtree home",
|
|
258
|
+
status=CheckStatus.FAIL,
|
|
259
|
+
detail=f"{root} does not exist as a directory",
|
|
260
|
+
blocking=True,
|
|
261
|
+
metadata={"path": str(root)},
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
try:
|
|
265
|
+
with tempfile.NamedTemporaryFile(dir=root, prefix=".doctor-", suffix=".probe"):
|
|
266
|
+
pass
|
|
267
|
+
except OSError as error:
|
|
268
|
+
return DoctorCheck(
|
|
269
|
+
id="techtree_home",
|
|
270
|
+
label="Techtree home",
|
|
271
|
+
status=CheckStatus.FAIL,
|
|
272
|
+
detail=f"{root} is not writable: {error.strerror or error}",
|
|
273
|
+
blocking=True,
|
|
274
|
+
metadata={"path": str(root)},
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
mode = stat.S_IMODE(os.stat(root).st_mode)
|
|
278
|
+
metadata["mode"] = f"0o{mode:03o}"
|
|
279
|
+
|
|
280
|
+
if mode != _PRIVATE_DIRECTORY_MODE:
|
|
281
|
+
return DoctorCheck(
|
|
282
|
+
id="techtree_home",
|
|
283
|
+
label="Techtree home",
|
|
284
|
+
status=CheckStatus.WARN,
|
|
285
|
+
detail=(
|
|
286
|
+
f"{root} is writable but its permissions are 0o{mode:03o}; "
|
|
287
|
+
"Techtree state is single-user and should be 0o700"
|
|
288
|
+
),
|
|
289
|
+
blocking=False,
|
|
290
|
+
metadata=dict(metadata),
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
return DoctorCheck(
|
|
294
|
+
id="techtree_home",
|
|
295
|
+
label="Techtree home",
|
|
296
|
+
status=CheckStatus.PASS,
|
|
297
|
+
detail=f"{root} is writable and private",
|
|
298
|
+
blocking=False,
|
|
299
|
+
metadata=dict(metadata),
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def check_uv_cli() -> DoctorCheck:
|
|
304
|
+
"""Find uv and report version."""
|
|
305
|
+
probe = _probe(["uv", "--version"], timeout=VERSION_TIMEOUT_SECONDS)
|
|
306
|
+
|
|
307
|
+
if not probe.found:
|
|
308
|
+
return DoctorCheck(
|
|
309
|
+
id="uv",
|
|
310
|
+
label="uv",
|
|
311
|
+
status=CheckStatus.WARN,
|
|
312
|
+
detail=(
|
|
313
|
+
"uv was not found on PATH; installing the managed evaluation "
|
|
314
|
+
"engine requires it"
|
|
315
|
+
),
|
|
316
|
+
blocking=False,
|
|
317
|
+
metadata={},
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
if not probe.succeeded:
|
|
321
|
+
return DoctorCheck(
|
|
322
|
+
id="uv",
|
|
323
|
+
label="uv",
|
|
324
|
+
status=CheckStatus.WARN,
|
|
325
|
+
detail=_probe_failure_detail("uv", probe),
|
|
326
|
+
blocking=False,
|
|
327
|
+
metadata={"executable": probe.executable},
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
return DoctorCheck(
|
|
331
|
+
id="uv",
|
|
332
|
+
label="uv",
|
|
333
|
+
status=CheckStatus.PASS,
|
|
334
|
+
detail=probe.output or "uv is available",
|
|
335
|
+
blocking=False,
|
|
336
|
+
metadata={"executable": probe.executable, "version": probe.output},
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def check_docker_cli() -> DoctorCheck:
|
|
341
|
+
"""Find docker executable."""
|
|
342
|
+
probe = _probe(["docker", "--version"], timeout=VERSION_TIMEOUT_SECONDS)
|
|
343
|
+
|
|
344
|
+
if not probe.found:
|
|
345
|
+
return DoctorCheck(
|
|
346
|
+
id="docker_cli",
|
|
347
|
+
label="Docker CLI",
|
|
348
|
+
status=CheckStatus.WARN,
|
|
349
|
+
detail=(
|
|
350
|
+
"docker was not found on PATH; running an evaluated subject "
|
|
351
|
+
"will need it"
|
|
352
|
+
),
|
|
353
|
+
blocking=False,
|
|
354
|
+
metadata={},
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
if not probe.succeeded:
|
|
358
|
+
return DoctorCheck(
|
|
359
|
+
id="docker_cli",
|
|
360
|
+
label="Docker CLI",
|
|
361
|
+
status=CheckStatus.WARN,
|
|
362
|
+
detail=_probe_failure_detail("docker", probe),
|
|
363
|
+
blocking=False,
|
|
364
|
+
metadata={"executable": probe.executable},
|
|
365
|
+
)
|
|
366
|
+
|
|
367
|
+
return DoctorCheck(
|
|
368
|
+
id="docker_cli",
|
|
369
|
+
label="Docker CLI",
|
|
370
|
+
status=CheckStatus.PASS,
|
|
371
|
+
detail=probe.output or "docker is available",
|
|
372
|
+
blocking=False,
|
|
373
|
+
metadata={"executable": probe.executable, "version": probe.output},
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def check_docker_daemon() -> DoctorCheck:
|
|
378
|
+
"""Check Docker server reachability."""
|
|
379
|
+
if shutil.which("docker") is None:
|
|
380
|
+
return DoctorCheck(
|
|
381
|
+
id="docker_daemon",
|
|
382
|
+
label="Docker daemon",
|
|
383
|
+
status=CheckStatus.SKIP,
|
|
384
|
+
detail="Skipped because the docker executable was not found",
|
|
385
|
+
blocking=False,
|
|
386
|
+
metadata={},
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
probe = _probe(
|
|
390
|
+
["docker", "version", "--format", "{{.Server.Os}}/{{.Server.Arch}}"],
|
|
391
|
+
timeout=DAEMON_TIMEOUT_SECONDS,
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
if not probe.succeeded or not probe.output:
|
|
395
|
+
return DoctorCheck(
|
|
396
|
+
id="docker_daemon",
|
|
397
|
+
label="Docker daemon",
|
|
398
|
+
status=CheckStatus.WARN,
|
|
399
|
+
detail=_probe_failure_detail("the Docker daemon", probe),
|
|
400
|
+
blocking=False,
|
|
401
|
+
metadata={},
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
return DoctorCheck(
|
|
405
|
+
id="docker_daemon",
|
|
406
|
+
label="Docker daemon",
|
|
407
|
+
status=CheckStatus.PASS,
|
|
408
|
+
detail=f"reachable, serving {probe.output}",
|
|
409
|
+
blocking=False,
|
|
410
|
+
metadata={"docker_platform": probe.output},
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
def check_hermes_cli() -> DoctorCheck:
|
|
415
|
+
"""Find Hermes and report version; warning only."""
|
|
416
|
+
probe = _probe(["hermes", "--version"], timeout=VERSION_TIMEOUT_SECONDS)
|
|
417
|
+
|
|
418
|
+
if not probe.found:
|
|
419
|
+
return DoctorCheck(
|
|
420
|
+
id="hermes",
|
|
421
|
+
label="Hermes",
|
|
422
|
+
status=CheckStatus.WARN,
|
|
423
|
+
detail=(
|
|
424
|
+
"hermes was not found on PATH. Techtree runs inside Hermes, an "
|
|
425
|
+
"open-source agent made by Nous Research; the CLI also works "
|
|
426
|
+
"on its own. The pinned installation guide for this release is "
|
|
427
|
+
f"{START_PAGE_URL}"
|
|
428
|
+
),
|
|
429
|
+
blocking=False,
|
|
430
|
+
metadata={},
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
if not probe.succeeded:
|
|
434
|
+
return DoctorCheck(
|
|
435
|
+
id="hermes",
|
|
436
|
+
label="Hermes",
|
|
437
|
+
status=CheckStatus.WARN,
|
|
438
|
+
detail=_probe_failure_detail("hermes", probe),
|
|
439
|
+
blocking=False,
|
|
440
|
+
metadata={"executable": probe.executable},
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
return DoctorCheck(
|
|
444
|
+
id="hermes",
|
|
445
|
+
label="Hermes",
|
|
446
|
+
status=CheckStatus.PASS,
|
|
447
|
+
detail=probe.output or "hermes is available",
|
|
448
|
+
blocking=False,
|
|
449
|
+
metadata={"executable": probe.executable, "version": probe.output},
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
def check_hermes_plugin() -> DoctorCheck:
|
|
454
|
+
"""Say whether the Techtree plugin is installed and on for the Hermes on PATH.
|
|
455
|
+
|
|
456
|
+
Never blocking, and never a failure. A host without the plugin is a
|
|
457
|
+
perfectly good host: the CLI does its whole job on its own, and the plugin
|
|
458
|
+
is what lets an agent drive it. So this is the same kind of observation
|
|
459
|
+
``check_active_engine`` makes about an engine that is not active yet — a
|
|
460
|
+
next step, written as one.
|
|
461
|
+
|
|
462
|
+
Installed and switched on are two questions, and a plugin can be the first
|
|
463
|
+
without being the second. Answering only the first would tell somebody in
|
|
464
|
+
that state that everything is fine while their agent still has no Techtree
|
|
465
|
+
commands, so both are answered and the second carries the command that
|
|
466
|
+
changes it.
|
|
467
|
+
|
|
468
|
+
The answer is only as good as what Hermes will say. Plugins are held per
|
|
469
|
+
profile as well as per user, so a listing describes the Hermes this
|
|
470
|
+
command resolves to and not necessarily another profile's. And a Hermes
|
|
471
|
+
that does not answer with a listing this build can read is reported as
|
|
472
|
+
unknown rather than guessed at: an unfounded "not installed" would send
|
|
473
|
+
someone to reinstall software they already have, and an unfounded "not
|
|
474
|
+
switched on" would send them to turn on what is already running.
|
|
475
|
+
"""
|
|
476
|
+
if shutil.which("hermes") is None:
|
|
477
|
+
return DoctorCheck(
|
|
478
|
+
id="hermes_plugin",
|
|
479
|
+
label="Techtree plugin",
|
|
480
|
+
status=CheckStatus.SKIP,
|
|
481
|
+
detail="Skipped because the hermes executable was not found",
|
|
482
|
+
blocking=False,
|
|
483
|
+
metadata={},
|
|
484
|
+
)
|
|
485
|
+
|
|
486
|
+
probe = _probe(
|
|
487
|
+
["hermes", "plugins", "list", "--json"], timeout=VERSION_TIMEOUT_SECONDS
|
|
488
|
+
)
|
|
489
|
+
listing = _plugin_states(probe)
|
|
490
|
+
|
|
491
|
+
if listing is None:
|
|
492
|
+
return DoctorCheck(
|
|
493
|
+
id="hermes_plugin",
|
|
494
|
+
label="Techtree plugin",
|
|
495
|
+
status=CheckStatus.SKIP,
|
|
496
|
+
detail=(
|
|
497
|
+
"Skipped because this Hermes did not return a plugin list this "
|
|
498
|
+
"build can read"
|
|
499
|
+
),
|
|
500
|
+
blocking=False,
|
|
501
|
+
metadata={"timed_out": probe.timed_out, "exit_code": probe.exit_code},
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
if TECHTREE_PLUGIN_NAME not in listing:
|
|
505
|
+
return DoctorCheck(
|
|
506
|
+
id="hermes_plugin",
|
|
507
|
+
label="Techtree plugin",
|
|
508
|
+
status=CheckStatus.WARN,
|
|
509
|
+
detail=(
|
|
510
|
+
"The Techtree plugin is not installed for this Hermes. The CLI "
|
|
511
|
+
"works without it, and installing it is what lets your agent "
|
|
512
|
+
"drive Techtree for you. The pinned installation guide for "
|
|
513
|
+
f"this release is {START_PAGE_URL}"
|
|
514
|
+
),
|
|
515
|
+
blocking=False,
|
|
516
|
+
metadata={"plugin_name": TECHTREE_PLUGIN_NAME, "installed": False},
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
state = listing[TECHTREE_PLUGIN_NAME]
|
|
520
|
+
|
|
521
|
+
if state == _ENABLED:
|
|
522
|
+
return DoctorCheck(
|
|
523
|
+
id="hermes_plugin",
|
|
524
|
+
label="Techtree plugin",
|
|
525
|
+
status=CheckStatus.PASS,
|
|
526
|
+
detail="The Techtree plugin is installed and switched on for this Hermes",
|
|
527
|
+
blocking=False,
|
|
528
|
+
metadata={
|
|
529
|
+
"plugin_name": TECHTREE_PLUGIN_NAME,
|
|
530
|
+
"installed": True,
|
|
531
|
+
"enabled": True,
|
|
532
|
+
},
|
|
533
|
+
)
|
|
534
|
+
|
|
535
|
+
if state in _NOT_ENABLED:
|
|
536
|
+
return DoctorCheck(
|
|
537
|
+
id="hermes_plugin",
|
|
538
|
+
label="Techtree plugin",
|
|
539
|
+
status=CheckStatus.WARN,
|
|
540
|
+
detail=(
|
|
541
|
+
"The Techtree plugin is installed for this Hermes but is not "
|
|
542
|
+
"switched on, so your agent cannot see Techtree's commands yet. "
|
|
543
|
+
"The CLI works either way. Switch it on with: hermes plugins "
|
|
544
|
+
f"enable {TECHTREE_PLUGIN_NAME}"
|
|
545
|
+
),
|
|
546
|
+
blocking=False,
|
|
547
|
+
metadata={
|
|
548
|
+
"plugin_name": TECHTREE_PLUGIN_NAME,
|
|
549
|
+
"installed": True,
|
|
550
|
+
"enabled": False,
|
|
551
|
+
},
|
|
552
|
+
)
|
|
553
|
+
|
|
554
|
+
return DoctorCheck(
|
|
555
|
+
id="hermes_plugin",
|
|
556
|
+
label="Techtree plugin",
|
|
557
|
+
status=CheckStatus.SKIP,
|
|
558
|
+
detail=(
|
|
559
|
+
"This Hermes lists the Techtree plugin but described its state in a "
|
|
560
|
+
"word this build does not know, so whether it is switched on could "
|
|
561
|
+
"not be established"
|
|
562
|
+
),
|
|
563
|
+
blocking=False,
|
|
564
|
+
metadata={"plugin_name": TECHTREE_PLUGIN_NAME, "installed": True},
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
def check_active_engine(paths: TechtreePaths, settings: Settings) -> DoctorCheck:
|
|
569
|
+
"""Report whether active engine is installed and verified.
|
|
570
|
+
|
|
571
|
+
Verification belongs to the managed engine subsystem, which this build does
|
|
572
|
+
not contain. Doctor therefore reports what the filesystem can prove — the
|
|
573
|
+
active pointer and whether anything is installed under it — and says
|
|
574
|
+
plainly that verified is not yet a state it can observe.
|
|
575
|
+
"""
|
|
576
|
+
digest = settings.active_engine_digest
|
|
577
|
+
|
|
578
|
+
if digest is None:
|
|
579
|
+
return DoctorCheck(
|
|
580
|
+
id="active_engine",
|
|
581
|
+
label="Active engine",
|
|
582
|
+
status=CheckStatus.WARN,
|
|
583
|
+
detail="No managed evaluation engine is active yet",
|
|
584
|
+
blocking=False,
|
|
585
|
+
metadata={"engine_status": EngineCompatibilityStatus.UNKNOWN.value},
|
|
586
|
+
)
|
|
587
|
+
|
|
588
|
+
directory = paths.engine_dir(digest)
|
|
589
|
+
if not directory.is_dir():
|
|
590
|
+
return DoctorCheck(
|
|
591
|
+
id="active_engine",
|
|
592
|
+
label="Active engine",
|
|
593
|
+
status=CheckStatus.WARN,
|
|
594
|
+
detail=(
|
|
595
|
+
f"engine {digest} is recorded as active but is not installed "
|
|
596
|
+
f"under {paths.engines_dir}"
|
|
597
|
+
),
|
|
598
|
+
blocking=False,
|
|
599
|
+
metadata={
|
|
600
|
+
"engine_status": EngineCompatibilityStatus.NOT_INSTALLED.value,
|
|
601
|
+
"engine_digest": digest,
|
|
602
|
+
},
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
engine_status = EngineRegistry(paths, settings).status(digest)
|
|
606
|
+
if engine_status.verified:
|
|
607
|
+
return DoctorCheck(
|
|
608
|
+
id="active_engine",
|
|
609
|
+
label="Active engine",
|
|
610
|
+
status=CheckStatus.PASS,
|
|
611
|
+
detail=f"engine {digest} is installed and verified",
|
|
612
|
+
blocking=False,
|
|
613
|
+
metadata={
|
|
614
|
+
"engine_status": EngineCompatibilityStatus.VERIFIED.value,
|
|
615
|
+
"engine_digest": digest,
|
|
616
|
+
},
|
|
617
|
+
)
|
|
618
|
+
|
|
619
|
+
return DoctorCheck(
|
|
620
|
+
id="active_engine",
|
|
621
|
+
label="Active engine",
|
|
622
|
+
status=CheckStatus.WARN,
|
|
623
|
+
detail=(
|
|
624
|
+
f"engine {digest} is installed but not verified; "
|
|
625
|
+
"run techtree setup to verify and activate it"
|
|
626
|
+
),
|
|
627
|
+
blocking=False,
|
|
628
|
+
metadata={
|
|
629
|
+
"engine_status": EngineCompatibilityStatus.INSTALLED_UNVERIFIED.value,
|
|
630
|
+
"engine_digest": digest,
|
|
631
|
+
},
|
|
632
|
+
)
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
def _plugin_states(probe: _Probe) -> dict[str, str | None] | None:
|
|
636
|
+
"""Map each listed plugin to the word beside it, or None if there is no listing.
|
|
637
|
+
|
|
638
|
+
None for the whole listing is the honest answer to every way this can go
|
|
639
|
+
wrong — a Hermes too old to know the flag, one that timed out, one that
|
|
640
|
+
answered with something other than the documented array of plugin objects.
|
|
641
|
+
Doctor says it does not know rather than reporting an absence it did not
|
|
642
|
+
observe.
|
|
643
|
+
|
|
644
|
+
A named plugin whose word is missing or is not text maps to None on its
|
|
645
|
+
own. Dropping such an entry would be worse than keeping it: the plugin was
|
|
646
|
+
listed, so reporting it as absent would be an absence nobody observed.
|
|
647
|
+
"""
|
|
648
|
+
if not probe.succeeded:
|
|
649
|
+
return None
|
|
650
|
+
try:
|
|
651
|
+
listing = json.loads(probe.stdout)
|
|
652
|
+
except ValueError:
|
|
653
|
+
return None
|
|
654
|
+
if not isinstance(listing, list):
|
|
655
|
+
return None
|
|
656
|
+
states = {
|
|
657
|
+
entry["name"]: entry["status"] if isinstance(entry.get("status"), str) else None
|
|
658
|
+
for entry in listing
|
|
659
|
+
if isinstance(entry, dict) and isinstance(entry.get("name"), str)
|
|
660
|
+
}
|
|
661
|
+
if listing and not states:
|
|
662
|
+
# A listing of somethings, none of which is a named plugin, is a shape
|
|
663
|
+
# this build does not understand. Reading it as "no plugins" would turn
|
|
664
|
+
# an unread answer into a claim about the host.
|
|
665
|
+
return None
|
|
666
|
+
return states
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
def _probe_failure_detail(subject: str, probe: _Probe) -> str:
|
|
670
|
+
"""Describe a tool that exists but did not answer."""
|
|
671
|
+
if probe.timed_out:
|
|
672
|
+
return f"{subject} did not answer within the timeout"
|
|
673
|
+
if probe.output:
|
|
674
|
+
return f"{subject} is present but reported: {probe.output}"
|
|
675
|
+
return f"{subject} is present but did not answer"
|