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.
Files changed (232) hide show
  1. tempergraph/__init__.py +8 -0
  2. tempergraph/__main__.py +5 -0
  3. tempergraph/api.py +428 -0
  4. tempergraph/audit/__init__.py +305 -0
  5. tempergraph/audit/catalog.py +342 -0
  6. tempergraph/audit/definition.py +387 -0
  7. tempergraph/audit/history.py +414 -0
  8. tempergraph/audit/history_rules.py +268 -0
  9. tempergraph/audit/history_rules_more.py +244 -0
  10. tempergraph/audit/host.py +270 -0
  11. tempergraph/audit/owned.py +96 -0
  12. tempergraph/audit/prompts.py +89 -0
  13. tempergraph/audit/report.py +248 -0
  14. tempergraph/audit/revisit.py +220 -0
  15. tempergraph/audit/surface.py +224 -0
  16. tempergraph/audit/text_health.py +176 -0
  17. tempergraph/audit/tools.py +391 -0
  18. tempergraph/author/__init__.py +2 -0
  19. tempergraph/author/blueprint.py +346 -0
  20. tempergraph/author/compare.py +122 -0
  21. tempergraph/author/criteria_lint.py +200 -0
  22. tempergraph/author/draw.py +112 -0
  23. tempergraph/author/inventory.py +210 -0
  24. tempergraph/author/literals.py +138 -0
  25. tempergraph/author/scaffold.py +568 -0
  26. tempergraph/author/session.py +439 -0
  27. tempergraph/author/trial.py +391 -0
  28. tempergraph/author/verify.py +353 -0
  29. tempergraph/builtin/__init__.py +1 -0
  30. tempergraph/builtin/upgrade.py +288 -0
  31. tempergraph/catalog.py +134 -0
  32. tempergraph/check_helpers.py +99 -0
  33. tempergraph/cli/__init__.py +1 -0
  34. tempergraph/cli/audit.py +190 -0
  35. tempergraph/cli/author.py +361 -0
  36. tempergraph/cli/improve.py +564 -0
  37. tempergraph/cli/improve_review.py +111 -0
  38. tempergraph/cli/install.py +35 -0
  39. tempergraph/cli/main.py +1261 -0
  40. tempergraph/cli/observe_cli.py +544 -0
  41. tempergraph/cli/outcome.py +77 -0
  42. tempergraph/cli/schedule_cli.py +1090 -0
  43. tempergraph/cli/upgrade.py +126 -0
  44. tempergraph/cli/workflows.py +96 -0
  45. tempergraph/compiler/__init__.py +6 -0
  46. tempergraph/compiler/graph.py +305 -0
  47. tempergraph/compiler/state.py +229 -0
  48. tempergraph/constants.py +72 -0
  49. tempergraph/contracts.py +1025 -0
  50. tempergraph/data/executor_compat.json +11 -0
  51. tempergraph/data/promotion.json +35 -0
  52. tempergraph/data/release.json +20 -0
  53. tempergraph/detach.py +65 -0
  54. tempergraph/docs.py +90 -0
  55. tempergraph/durability/__init__.py +2 -0
  56. tempergraph/durability/alias.py +66 -0
  57. tempergraph/durability/carry.py +591 -0
  58. tempergraph/durability/checkpoint.py +179 -0
  59. tempergraph/durability/control.py +109 -0
  60. tempergraph/durability/engine_file.py +301 -0
  61. tempergraph/durability/lock.py +138 -0
  62. tempergraph/durability/status.py +390 -0
  63. tempergraph/engine_identity.py +42 -0
  64. tempergraph/executor_compat.py +56 -0
  65. tempergraph/executors/__init__.py +4 -0
  66. tempergraph/executors/binding.py +91 -0
  67. tempergraph/executors/capabilities.py +95 -0
  68. tempergraph/executors/claude.py +603 -0
  69. tempergraph/executors/launcher.py +394 -0
  70. tempergraph/executors/mcpconfig.py +156 -0
  71. tempergraph/executors/mcpproxy.py +216 -0
  72. tempergraph/executors/preflight.py +196 -0
  73. tempergraph/executors/registry.py +71 -0
  74. tempergraph/executors/scripted.py +18 -0
  75. tempergraph/executors/session.py +107 -0
  76. tempergraph/executors/standins.py +118 -0
  77. tempergraph/executors/summary.py +110 -0
  78. tempergraph/executors/viewcatalog.py +27 -0
  79. tempergraph/git.py +403 -0
  80. tempergraph/identity.py +65 -0
  81. tempergraph/improve/__init__.py +5 -0
  82. tempergraph/improve/analysis.py +437 -0
  83. tempergraph/improve/artifact.py +477 -0
  84. tempergraph/improve/autonomy.py +192 -0
  85. tempergraph/improve/bindings.py +191 -0
  86. tempergraph/improve/calibration.py +1016 -0
  87. tempergraph/improve/causes.py +416 -0
  88. tempergraph/improve/child.py +651 -0
  89. tempergraph/improve/codehost.py +520 -0
  90. tempergraph/improve/digest.py +472 -0
  91. tempergraph/improve/escape.py +100 -0
  92. tempergraph/improve/filing.py +1047 -0
  93. tempergraph/improve/harvest.py +158 -0
  94. tempergraph/improve/issue_context.py +192 -0
  95. tempergraph/improve/lenses.py +204 -0
  96. tempergraph/improve/lessons.py +233 -0
  97. tempergraph/improve/loop_report.py +138 -0
  98. tempergraph/improve/loop_summary.py +85 -0
  99. tempergraph/improve/lost.py +119 -0
  100. tempergraph/improve/measure.py +121 -0
  101. tempergraph/improve/params.py +98 -0
  102. tempergraph/improve/pause_facts.py +134 -0
  103. tempergraph/improve/pr_later.py +186 -0
  104. tempergraph/improve/prebinding.py +130 -0
  105. tempergraph/improve/promotion.py +413 -0
  106. tempergraph/improve/proposals.py +934 -0
  107. tempergraph/improve/record.py +322 -0
  108. tempergraph/improve/release.py +89 -0
  109. tempergraph/improve/reliability.py +457 -0
  110. tempergraph/improve/repeat.py +115 -0
  111. tempergraph/improve/review.py +910 -0
  112. tempergraph/improve/suites.py +586 -0
  113. tempergraph/improve/trials.py +525 -0
  114. tempergraph/install/__init__.py +11 -0
  115. tempergraph/install/bootstrap.py +133 -0
  116. tempergraph/install/environment.py +173 -0
  117. tempergraph/install/launch.py +37 -0
  118. tempergraph/install/python.py +53 -0
  119. tempergraph/install/reconcile.py +52 -0
  120. tempergraph/install/selfcheck.py +29 -0
  121. tempergraph/install/shim.py +81 -0
  122. tempergraph/install/update.py +400 -0
  123. tempergraph/model/__init__.py +0 -0
  124. tempergraph/model/diagram.py +185 -0
  125. tempergraph/model/flow.py +324 -0
  126. tempergraph/model/prompt_lint.py +203 -0
  127. tempergraph/model/retire.py +52 -0
  128. tempergraph/model/subworkflow.py +274 -0
  129. tempergraph/model/text.py +67 -0
  130. tempergraph/model/validate.py +1158 -0
  131. tempergraph/observe/__init__.py +1 -0
  132. tempergraph/observe/attention.py +196 -0
  133. tempergraph/observe/detail.py +773 -0
  134. tempergraph/observe/forget.py +138 -0
  135. tempergraph/observe/hooks.py +272 -0
  136. tempergraph/observe/labels.py +95 -0
  137. tempergraph/observe/overlay.py +46 -0
  138. tempergraph/observe/report.py +402 -0
  139. tempergraph/observe/risk_report.py +110 -0
  140. tempergraph/observe/rows.py +444 -0
  141. tempergraph/observe/sinks.py +793 -0
  142. tempergraph/observe/supervision_cost.py +797 -0
  143. tempergraph/observe/supervision_report.py +295 -0
  144. tempergraph/observe/switch_report.py +140 -0
  145. tempergraph/package/__init__.py +2 -0
  146. tempergraph/package/change_report.py +116 -0
  147. tempergraph/package/changelog.py +263 -0
  148. tempergraph/package/docs_check.py +115 -0
  149. tempergraph/package/importer.py +90 -0
  150. tempergraph/package/inventory.py +111 -0
  151. tempergraph/package/loader.py +250 -0
  152. tempergraph/package/manifest.py +256 -0
  153. tempergraph/package/readiness.py +124 -0
  154. tempergraph/package/registry.py +383 -0
  155. tempergraph/package/rules.py +128 -0
  156. tempergraph/package/scan.py +65 -0
  157. tempergraph/package/selftest.py +348 -0
  158. tempergraph/package/stamp.py +213 -0
  159. tempergraph/package/transforms.py +481 -0
  160. tempergraph/package/upgrade.py +625 -0
  161. tempergraph/provenance.py +183 -0
  162. tempergraph/py.typed +0 -0
  163. tempergraph/release.py +17 -0
  164. tempergraph/render/__init__.py +0 -0
  165. tempergraph/render/output.py +72 -0
  166. tempergraph/render/prompt.py +166 -0
  167. tempergraph/render/template.py +86 -0
  168. tempergraph/run/__init__.py +2 -0
  169. tempergraph/run/asking.py +233 -0
  170. tempergraph/run/audit.py +63 -0
  171. tempergraph/run/check_worker.py +167 -0
  172. tempergraph/run/checks.py +517 -0
  173. tempergraph/run/commands.py +210 -0
  174. tempergraph/run/complexity.py +268 -0
  175. tempergraph/run/contest.py +76 -0
  176. tempergraph/run/council.py +368 -0
  177. tempergraph/run/council_run.py +527 -0
  178. tempergraph/run/events.py +279 -0
  179. tempergraph/run/finalize.py +132 -0
  180. tempergraph/run/gate.py +747 -0
  181. tempergraph/run/guard.py +89 -0
  182. tempergraph/run/judging.py +357 -0
  183. tempergraph/run/ladder.py +230 -0
  184. tempergraph/run/log.py +600 -0
  185. tempergraph/run/mapping.py +183 -0
  186. tempergraph/run/nodes.py +2304 -0
  187. tempergraph/run/outcome.py +255 -0
  188. tempergraph/run/outcome_record.py +292 -0
  189. tempergraph/run/outcome_trust.py +99 -0
  190. tempergraph/run/rerun.py +351 -0
  191. tempergraph/run/reserve.py +85 -0
  192. tempergraph/run/resources.py +76 -0
  193. tempergraph/run/risk.py +231 -0
  194. tempergraph/run/runner.py +1579 -0
  195. tempergraph/run/scriptcache.py +178 -0
  196. tempergraph/run/selfcheck.py +105 -0
  197. tempergraph/run/session_record.py +72 -0
  198. tempergraph/run/subrun.py +278 -0
  199. tempergraph/run/supervision.py +125 -0
  200. tempergraph/run/tool_access.py +101 -0
  201. tempergraph/schedule/__init__.py +25 -0
  202. tempergraph/schedule/credentials.py +167 -0
  203. tempergraph/schedule/echo.py +169 -0
  204. tempergraph/schedule/exact.py +275 -0
  205. tempergraph/schedule/export.py +164 -0
  206. tempergraph/schedule/launch.py +89 -0
  207. tempergraph/schedule/ledger.py +133 -0
  208. tempergraph/schedule/loop.py +176 -0
  209. tempergraph/schedule/model.py +440 -0
  210. tempergraph/schedule/policies.py +414 -0
  211. tempergraph/schedule/store.py +150 -0
  212. tempergraph/schedule/tick.py +377 -0
  213. tempergraph/schedule/token.py +81 -0
  214. tempergraph/schedule/triggers.py +210 -0
  215. tempergraph/schedule/words.py +423 -0
  216. tempergraph/security/__init__.py +0 -0
  217. tempergraph/security/launch.py +25 -0
  218. tempergraph/security/scrub.py +58 -0
  219. tempergraph/settings.py +950 -0
  220. tempergraph/store/__init__.py +0 -0
  221. tempergraph/store/codelog.py +73 -0
  222. tempergraph/store/layout.py +198 -0
  223. tempergraph/store/logs.py +325 -0
  224. tempergraph/store/manifest.py +99 -0
  225. tempergraph/store/migrate.py +188 -0
  226. tempergraph/workspace.py +874 -0
  227. tempergraph-0.7.1.dist-info/METADATA +70 -0
  228. tempergraph-0.7.1.dist-info/RECORD +232 -0
  229. tempergraph-0.7.1.dist-info/WHEEL +5 -0
  230. tempergraph-0.7.1.dist-info/entry_points.txt +5 -0
  231. tempergraph-0.7.1.dist-info/top_level.txt +2 -0
  232. tempergraph_pytest_plugin.py +64 -0
@@ -0,0 +1,91 @@
1
+ """The per-machine binding table (EXI-B18, EXI-B28, EXI-B29, SEC-B1).
2
+
3
+ The table lives at ``<home>/config/bindings.json``. A typed alias only selects an entry; the entry's
4
+ value, never the typed text, reaches argv. With no file, each executor's built-in tiers apply.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import re
10
+ from collections.abc import Mapping
11
+ from dataclasses import dataclass, field
12
+ from pathlib import Path
13
+ from typing import Any
14
+
15
+ from tempergraph.docs import read_json
16
+ from tempergraph.store.layout import home_path
17
+
18
+ BINDINGS_FILE = "bindings.json"
19
+
20
+ # Built-in tiers when the operator file has no row (research `claude-code-cli-headless` F10: the CLI takes these model names).
21
+ DEFAULT_TIERS: dict[str, dict[str, str]] = {
22
+ "claude": {"small": "haiku", "medium": "sonnet", "large": "opus"},
23
+ "agent-sdk": {"small": "haiku", "medium": "sonnet", "large": "opus"},
24
+ }
25
+
26
+ _MODEL_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._:@/\[\]-]{0,127}$")
27
+
28
+
29
+ class BindingError(ValueError):
30
+ """An alias with no entry, or an entry whose value is not a plain model name."""
31
+
32
+
33
+ @dataclass(frozen=True, kw_only=True)
34
+ class Binding:
35
+ executor: str
36
+ tiers: Mapping[str, str] = field(default_factory=dict)
37
+ aliases: Mapping[str, str] = field(default_factory=dict)
38
+ prices: Mapping[str, Mapping[str, float]] = field(default_factory=dict)
39
+ provider: str | None = None
40
+
41
+ def qualified(self) -> frozenset[str]:
42
+ return frozenset(f"{self.executor}:{name}" for name in self.aliases)
43
+
44
+ def model(self, alias: str) -> str | None:
45
+ """The bound model name for ``alias``; None for ``inherit`` (the CLI's own default)."""
46
+ if alias == "inherit":
47
+ return None
48
+ if alias in self.tiers:
49
+ value = self.tiers[alias]
50
+ elif alias.startswith(self.executor + ":") and alias.split(":", 1)[1] in self.aliases:
51
+ value = self.aliases[alias.split(":", 1)[1]]
52
+ else:
53
+ raise BindingError(f"alias-unbound: {alias} on {self.executor}")
54
+ if not _MODEL_RE.match(value):
55
+ raise BindingError(f"binding-value-invalid: {alias} on {self.executor}")
56
+ return value
57
+
58
+
59
+ @dataclass(frozen=True, kw_only=True)
60
+ class BindingTable:
61
+ rows: Mapping[str, Binding] = field(default_factory=dict)
62
+
63
+ def for_executor(self, name: str) -> Binding:
64
+ if name in self.rows:
65
+ return self.rows[name]
66
+ return Binding(executor=name, tiers=DEFAULT_TIERS.get(name, {}))
67
+
68
+
69
+ def _row(executor: str, data: Mapping[str, Any]) -> Binding:
70
+ tiers = dict(DEFAULT_TIERS.get(executor, {}))
71
+ tiers.update({str(k): str(v) for k, v in (data.get("tiers") or {}).items()})
72
+ return Binding(
73
+ executor=executor,
74
+ tiers=tiers,
75
+ aliases={str(k): str(v) for k, v in (data.get("aliases") or {}).items()},
76
+ prices={str(k): dict(v) for k, v in (data.get("prices") or {}).items()},
77
+ provider=data.get("provider"),
78
+ )
79
+
80
+
81
+ def load(home: Path | None = None) -> BindingTable:
82
+ """Read the operator's table; unknown keys are ignored (CON-B14, CON-B1, CON-B15 tolerant reader)."""
83
+ path = (home or home_path()) / "config" / BINDINGS_FILE
84
+ if not path.exists():
85
+ return BindingTable()
86
+ doc = read_json(path, "bindings")
87
+ rows = {}
88
+ for item in doc.get("bindings", []):
89
+ if isinstance(item, dict) and isinstance(item.get("executor"), str):
90
+ rows[item["executor"]] = _row(item["executor"], item)
91
+ return BindingTable(rows=rows)
@@ -0,0 +1,95 @@
1
+ """Declared capability sets of the four designed executors (EXI-B16 to EXI-B24, ECC-B6, EAS, EMA, EAG-B8).
2
+
3
+ Release 1 registers `claude` only (ADR `first-release-ships-the-claude-executor-only`); the other three sets are declarations used by the scripted
4
+ stand-ins and the conformance suite, so CON-AC5 and WFM-AC5 hold against all four before their
5
+ adapters ship. A capability resting on an unrun probe is declared false (ADR `judge-isolation-per-executor`).
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from tempergraph.contracts import Capabilities
11
+
12
+ TIERS = frozenset({"small", "medium", "large", "inherit"})
13
+
14
+ _CLAUDE_TOOLS: dict[str, tuple[str, ...]] = {
15
+ "read": ("Read",), "search": ("Grep",), "list": ("Glob",), "edit": ("Edit",), "write": ("Write",),
16
+ "shell": ("Bash",), "web_fetch": ("WebFetch",), "web_search": ("WebSearch",), "subagent": ("Agent", "Task"),
17
+ "mcp:*": ("mcp__{server}__{tool}",), "skill:*": ("Skill",),
18
+ }
19
+
20
+ CLAUDE = Capabilities(
21
+ name="claude",
22
+ binds_aliases=TIERS,
23
+ families={"small": "anthropic", "medium": "anthropic", "large": "anthropic", "inherit": "anthropic"},
24
+ prompt_off_argv=True, streams_events=True, reports_actions=True, reports_tokens=True, reports_cost=True,
25
+ enforces_step_tools=True, step_allow_rules=True, fresh_session=True,
26
+ restricts_judge_tools=True,
27
+ judge_mcp=True, # the engine's filtering MCP proxy fronts a local server (ECC-B3); ADR a-judge-reaches-an-mcp-server-only-through-the-engines-filtering-proxy
28
+ isolates_user_config=False, # true once P-CC-1 is confirmed (ECC-B6)
29
+ hosts_authoring_surface=True,
30
+ efforts_uncertain=frozenset({"xhigh", "max"}), # until live probe P-LAD-1 (LAD-B14)
31
+ session_options=frozenset({"effort", "cost_cap_usd", "fallback_alias", "turn_cap"}),
32
+ tool_map=_CLAUDE_TOOLS,
33
+ unattended_credentials=frozenset({"api_key", "cloud", "oauth_token", "interactive_login"}), # TCK-B19
34
+ )
35
+
36
+ AGENT_SDK = Capabilities(
37
+ name="agent-sdk",
38
+ binds_aliases=TIERS,
39
+ families={"small": "anthropic", "medium": "anthropic", "large": "anthropic", "inherit": "anthropic"},
40
+ prompt_off_argv=True, streams_events=True, reports_actions=True, reports_tokens=True, reports_cost=True,
41
+ fresh_session=True, enforces_step_tools=True, step_allow_rules=True, judge_mcp=True,
42
+ restricts_judge_tools=True, isolates_user_config=False, hosts_authoring_surface=True,
43
+ efforts_uncertain=frozenset({"xhigh", "max"}), # until live probe P-LAD-1 (LAD-B14)
44
+ session_options=frozenset({"effort", "cost_cap_usd", "fallback_alias", "turn_cap"}),
45
+ tool_map=dict(_CLAUDE_TOOLS),
46
+ unattended_credentials=frozenset({"api_key", "cloud"}), # TCK-B19
47
+ )
48
+
49
+ MESSAGES_API = Capabilities(
50
+ name="messages-api",
51
+ binds_aliases=TIERS,
52
+ families={"small": "anthropic", "medium": "anthropic", "large": "anthropic", "inherit": "anthropic"},
53
+ prompt_off_argv=True, streams_events=True, reports_actions=True, reports_tokens=True, reports_cost=False,
54
+ fresh_session=True, enforces_step_tools=True, restricts_judge_tools=True, isolates_user_config=True,
55
+ step_allow_rules=True, judge_mcp=True, hosts_authoring_surface=False,
56
+ session_options=frozenset({"effort", "cost_cap_usd", "turn_cap"}),
57
+ tool_map={
58
+ "read": ("read_file",), "search": ("search_files",), "list": ("list_files",), "edit": ("edit_file",),
59
+ "write": ("write_file",), "shell": ("run_command",), "web_fetch": ("web_fetch",),
60
+ "web_search": ("web_search",), "mcp:*": ("mcp__{server}__{tool}",),
61
+ },
62
+ unattended_credentials=frozenset({"api_key", "cloud"}), # TCK-B19
63
+ )
64
+
65
+ ANTIGRAVITY = Capabilities(
66
+ name="antigravity",
67
+ binds_aliases=TIERS,
68
+ families={"small": "google", "medium": "google", "large": "google", "inherit": "google"},
69
+ prompt_off_argv=True, streams_events=True, reports_actions=True, reports_tokens=True, reports_cost=False,
70
+ fresh_session=True, isolates_user_config=False, enforces_step_tools=False, judge_mcp=False,
71
+ restricts_judge_tools=False, step_allow_rules=True, hosts_authoring_surface=True,
72
+ efforts=frozenset({"low", "medium", "high"}),
73
+ session_options=frozenset({"effort"}),
74
+ tool_map={
75
+ "read": ("view_file",), "search": ("grep_search",), "list": ("list_dir", "find_by_name"),
76
+ "edit": ("replace_file_content", "multi_replace_file_content"), "write": ("write_to_file",),
77
+ "shell": ("run_command",), "web_fetch": ("read_url_content",), "web_search": ("search_web",),
78
+ "subagent": ("invoke_subagent",), "mcp:*": ("mcp({server}/{tool})",),
79
+ },
80
+ unattended_credentials=frozenset({"api_key"}), # `interactive_login` is refused until P-SCH-3 confirms it (TCK-B19)
81
+ )
82
+
83
+ DECLARED: dict[str, Capabilities] = {c.name: c for c in (CLAUDE, AGENT_SDK, MESSAGES_API, ANTIGRAVITY)}
84
+
85
+
86
+ def tool_names(caps: Capabilities, capability: str) -> tuple[str, ...]:
87
+ """The executor's tool names for one capability, with MCP names filled in."""
88
+ if capability in caps.tool_map:
89
+ return caps.tool_map[capability]
90
+ if capability.startswith("mcp:") and "mcp:*" in caps.tool_map:
91
+ server, tool = capability[4:].split("/", 1)
92
+ return tuple(t.format(server=server, tool=tool) for t in caps.tool_map["mcp:*"])
93
+ if capability.startswith("skill:") and "skill:*" in caps.tool_map:
94
+ return caps.tool_map["skill:*"]
95
+ return ()