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 @@
|
|
|
1
|
+
"""Read-only views built from the run documents (RDD; OVR-B15)."""
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"""`attention` (CLI-B6, AC-5): everything waiting on a person, oldest first, with the command that answers it.
|
|
2
|
+
|
|
3
|
+
Built from the status document of each state root and the last `pause` record of each paused thread, and from the
|
|
4
|
+
schedules of the home store (the items of TCK-B24 and `trigger_stale`, TCK-B7); reads only and calls no model (OVR-B15).
|
|
5
|
+
Orchestration items join with orchestration (release 4).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from collections.abc import Mapping
|
|
11
|
+
from datetime import UTC, datetime
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
from tempergraph.contracts import WorkflowSpec
|
|
16
|
+
from tempergraph.durability import carry as carrymod
|
|
17
|
+
from tempergraph.durability.status import status
|
|
18
|
+
from tempergraph.run.events import records
|
|
19
|
+
from tempergraph.store.layout import run_dir
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _since(text: Any) -> float | None:
|
|
23
|
+
try:
|
|
24
|
+
return datetime.fromisoformat(str(text).replace("Z", "+00:00")).timestamp()
|
|
25
|
+
except ValueError:
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def items(state_root: Path, specs: Mapping[str, WorkflowSpec], now: float | None = None) -> list[dict[str, Any]]:
|
|
30
|
+
now = datetime.now(UTC).timestamp() if now is None else now
|
|
31
|
+
out: list[dict[str, Any]] = []
|
|
32
|
+
for row in status(state_root, specs)["threads"]:
|
|
33
|
+
gates = row.get("pending_gates") or []
|
|
34
|
+
if row.get("state") == "paused" and gates:
|
|
35
|
+
wf, _, task = str(row["thread_id"]).partition("/")
|
|
36
|
+
pauses: dict[str, dict[str, Any]] = {}
|
|
37
|
+
for r in records(run_dir(state_root, wf, task) / "run.jsonl"):
|
|
38
|
+
if r.get("kind") == "pause" and r.get("unit"):
|
|
39
|
+
pauses[str(r["unit"])] = r
|
|
40
|
+
for g in gates:
|
|
41
|
+
p = pauses.get(str(g.get("unit"))) or {}
|
|
42
|
+
since = _since(p.get("ts"))
|
|
43
|
+
reason = p.get("question") or p.get("reason") or g.get("kind")
|
|
44
|
+
out.append({"thread_id": row["thread_id"], "workflow": row.get("workflow"), "alias": row.get("alias"),
|
|
45
|
+
"unit": g.get("unit"), "item": g.get("item"), "kind": g.get("kind"),
|
|
46
|
+
"waiting_since": p.get("ts"), "age_s": round(now - since, 1) if since else None,
|
|
47
|
+
"reason": reason, "decisions": p.get("decisions"), "command": g.get("resume"),
|
|
48
|
+
"state_root": str(state_root),
|
|
49
|
+
**({"schedule": row["schedule"]} if row.get("schedule") else {})}) # TCK-B4: a scheduled run's pause
|
|
50
|
+
elif row.get("carry") == "delete_failed": # CAR-B11: remote refused the state-branch deletion at finish
|
|
51
|
+
wf, _, task = str(row["thread_id"]).partition("/")
|
|
52
|
+
branch = carrymod.branch_name(wf, task)
|
|
53
|
+
out.append({"thread_id": row["thread_id"], "workflow": row.get("workflow"), "alias": row.get("alias"),
|
|
54
|
+
"unit": None, "item": None, "kind": "carry_delete_failed",
|
|
55
|
+
"waiting_since": None, "age_s": None,
|
|
56
|
+
"reason": f"remote refused deletion of {branch}",
|
|
57
|
+
"decisions": None, "command": f"tempergraph carry drop {wf} {task}",
|
|
58
|
+
"state_root": str(state_root)})
|
|
59
|
+
return out
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
STALE_INTERVALS = 3 # TCK-B7: a heartbeat older than this many tick intervals is stale
|
|
63
|
+
BLOCKING_AT = 3 # SCH-B22: overlap skips behind one unfinished fire
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _item(kind: str, sid: str, reason: str, command: str, at: Any, now: float, **extra: Any) -> dict[str, Any]:
|
|
67
|
+
since = _since(at)
|
|
68
|
+
return {"thread_id": None, "workflow": None, "alias": None, "unit": None, "item": None, "kind": kind,
|
|
69
|
+
"schedule_id": sid, "waiting_since": at, "age_s": round(now - since, 1) if since else None, "reason": reason,
|
|
70
|
+
"decisions": None, "command": command, "state_root": None, **extra}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _last(log: list[dict[str, Any]], kind: str, reason: str | None = None) -> dict[str, Any] | None:
|
|
74
|
+
return next((e for e in reversed(log) if e.get("kind") == kind and (reason is None or e.get("reason") == reason)), None)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def trigger_stale(home: Path | None = None, now: float | None = None) -> dict[str, Any] | None:
|
|
78
|
+
"""TCK-B7: active schedules and a `last_tick_at` older than three intervals; reads only."""
|
|
79
|
+
from tempergraph.schedule import store, tick
|
|
80
|
+
|
|
81
|
+
now = datetime.now(UTC).timestamp() if now is None else now
|
|
82
|
+
beat = tick.read_heartbeat(home)
|
|
83
|
+
if not beat or not any(e.get("state") == "active" for e in store.list_entries(home)):
|
|
84
|
+
return None
|
|
85
|
+
last = _since(beat.get("last_tick_at"))
|
|
86
|
+
interval = int(beat.get("interval_s") or 60)
|
|
87
|
+
if last is None or now - last <= STALE_INTERVALS * interval:
|
|
88
|
+
return None
|
|
89
|
+
return {"kind": "trigger_stale", "age_s": round(now - last, 1), "interval_s": interval, "last_tick_at": beat.get("last_tick_at"),
|
|
90
|
+
"command": "tempergraph schedule trigger status"}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def schedule_items(home: Path | None = None, now: float | None = None) -> list[dict[str, Any]]:
|
|
94
|
+
"""TCK-B24: `schedule_missed`, `schedule_paused`, `schedule_budget`, `schedule_refused` and `blocking_schedule`,
|
|
95
|
+
read from the schedules' entries and fire logs; each names its schedule and the command that answers it."""
|
|
96
|
+
from tempergraph.schedule import store
|
|
97
|
+
|
|
98
|
+
now = datetime.now(UTC).timestamp() if now is None else now
|
|
99
|
+
out: list[dict[str, Any]] = []
|
|
100
|
+
for entry in store.list_entries(home):
|
|
101
|
+
sid, state = str(entry["schedule_id"]), entry.get("state")
|
|
102
|
+
if state == "removed":
|
|
103
|
+
continue
|
|
104
|
+
log = store.read_log(sid, home)
|
|
105
|
+
if state == "paused" and (p := _last(log, "paused", "failures")):
|
|
106
|
+
out.append(_item("schedule_paused", sid, f"paused after {p.get('failures')} failures",
|
|
107
|
+
f"tempergraph schedule resume {sid}", p.get("at"), now))
|
|
108
|
+
if (entry.get("when") or {}).get("kind") == "once" and (m := _last(log, "missed")):
|
|
109
|
+
out.append(_item("schedule_missed", sid, f"the one-time slot {m.get('slot')} passed unstarted",
|
|
110
|
+
f"tempergraph schedule fire {sid}", m.get("at"), now))
|
|
111
|
+
if b := _last(log, "skipped", "budget"):
|
|
112
|
+
out.append(_item("schedule_budget", sid, f"the {(entry.get('budget') or {}).get('period')} budget is spent",
|
|
113
|
+
f"tempergraph schedule edit {sid} --budget <period>:<usd>", b.get("at"), now))
|
|
114
|
+
handled = [e for e in log if e.get("kind") in ("started", "skipped", "missed", "refused")]
|
|
115
|
+
if handled and handled[-1].get("kind") == "refused":
|
|
116
|
+
r = handled[-1]
|
|
117
|
+
who = f" ({r['executor']})" if r.get("executor") else ""
|
|
118
|
+
out.append(_item("schedule_refused", sid, f"{r.get('reason')}{who}: {r.get('message') or 'the fire was refused'}",
|
|
119
|
+
f"tempergraph schedule show {sid}", r.get("at"), now, executor=r.get("executor")))
|
|
120
|
+
ended = {e.get("fire_id") for e in log if e.get("kind") == "ended"}
|
|
121
|
+
open_fire = next((e for e in reversed(log) if e.get("kind") == "started" and e.get("fire_id") not in ended), None)
|
|
122
|
+
if open_fire is not None:
|
|
123
|
+
n = sum(1 for e in log if e.get("kind") == "skipped" and e.get("reason") == "overlap"
|
|
124
|
+
and str(e.get("at") or "") >= str(open_fire.get("at") or ""))
|
|
125
|
+
if n >= BLOCKING_AT:
|
|
126
|
+
out.append(_item("blocking_schedule", sid, f"{n} slots were skipped behind {open_fire.get('thread')}",
|
|
127
|
+
f"tempergraph status {open_fire.get('thread')}", open_fire.get("at"), now,
|
|
128
|
+
blocking_schedule=n))
|
|
129
|
+
return out
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def loop_summaries(state_root: Path) -> list[dict[str, Any]]:
|
|
133
|
+
"""CLI-B20: for each workflow, its newest `loop_summary` when it holds a finding, an observation or a failed review
|
|
134
|
+
(`review_failed`, the failed reviews by error class; `{}` in an older summary). Reads only."""
|
|
135
|
+
from tempergraph.improve import loop_summary
|
|
136
|
+
|
|
137
|
+
out: list[dict[str, Any]] = []
|
|
138
|
+
base = state_root / "runs"
|
|
139
|
+
for wdir in sorted(base.iterdir()) if base.is_dir() else ():
|
|
140
|
+
s = loop_summary.newest(state_root, wdir.name) if wdir.is_dir() else None
|
|
141
|
+
held = s.get("review_failed") if s is not None else None
|
|
142
|
+
failed = {str(k): int(v) for k, v in held.items()} if isinstance(held, dict) else {}
|
|
143
|
+
if s is None or not (s.get("recorded") or s.get("top") or failed):
|
|
144
|
+
continue
|
|
145
|
+
thread = str(s.get("thread") or "")
|
|
146
|
+
out.append({"workflow": wdir.name, "thread": thread, "at": s.get("ts"), "recorded": int(s.get("recorded") or 0),
|
|
147
|
+
"filed": int(s.get("filed") or 0), "top": list(s.get("top") or []), "review_failed": failed,
|
|
148
|
+
"command": f"tempergraph improve review show {thread}", "state_root": str(state_root)})
|
|
149
|
+
return out
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def attention(roots: list[Path], specs: Mapping[str, WorkflowSpec], now: float | None = None,
|
|
153
|
+
home: Path | None = None) -> dict[str, Any]:
|
|
154
|
+
found: list[dict[str, Any]] = []
|
|
155
|
+
loop: list[dict[str, Any]] = []
|
|
156
|
+
missing = []
|
|
157
|
+
for root in roots:
|
|
158
|
+
if not root.is_dir():
|
|
159
|
+
missing.append(str(root))
|
|
160
|
+
continue
|
|
161
|
+
found += items(root, specs, now)
|
|
162
|
+
loop += loop_summaries(root)
|
|
163
|
+
found += schedule_items(home, now)
|
|
164
|
+
found.sort(key=lambda i: (i["waiting_since"] is None, i["waiting_since"] or ""))
|
|
165
|
+
loop.sort(key=lambda s: str(s.get("at") or ""), reverse=True) # newest first
|
|
166
|
+
doc: dict[str, Any] = {"schema_version": 1, "items": found, "loop": loop, "missing_roots": missing}
|
|
167
|
+
stale = trigger_stale(home, now)
|
|
168
|
+
if stale:
|
|
169
|
+
doc["trigger_stale"] = stale # TCK-B7
|
|
170
|
+
return doc
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def loop_line(s: dict[str, Any]) -> str:
|
|
174
|
+
"""The text form of one summary: the counts, the failed reviews by error class when any (`16 reviews failed:
|
|
175
|
+
usage_limit 16`), then each observation, then the command (no note text)."""
|
|
176
|
+
rows = "".join(f"\n {o.get('category')} {o.get('unit')} {o.get('confidence')}" for o in s.get("top") or [])
|
|
177
|
+
failed = s.get("review_failed") or {}
|
|
178
|
+
lost = f", {sum(failed.values())} reviews failed: " + ", ".join(f"{k} {n}" for k, n in sorted(failed.items())) \
|
|
179
|
+
if failed else ""
|
|
180
|
+
return f" loop {s['thread']}: {s['recorded']} recorded, {s['filed']} filed{lost}{rows}\n {s['command']}"
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def stale_line(s: dict[str, Any]) -> str:
|
|
184
|
+
return (f" trigger_stale no tick for {int(s['age_s'] // 60)}m (interval {s['interval_s']}s)\n"
|
|
185
|
+
f" {s['command']}")
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def line(i: dict[str, Any]) -> str:
|
|
189
|
+
age = i.get("age_s")
|
|
190
|
+
when = "?" if age is None else f"{int(age // 3600)}h{int(age % 3600 // 60):02d}m" if age >= 3600 \
|
|
191
|
+
else f"{int(age // 60)}m"
|
|
192
|
+
if i.get("schedule_id") and not i.get("unit"): # a schedule item (TCK-B24)
|
|
193
|
+
return f"{when:>6} {i['kind']} {i['schedule_id']}: {i['reason']}\n {i['command']}"
|
|
194
|
+
where = f"{i['unit']}" + (f"[{i['item']}]" if i.get("item") else "")
|
|
195
|
+
sched = f" (schedule {i['schedule']['schedule_id']})" if i.get("schedule") else ""
|
|
196
|
+
return f"{when:>6} {i.get('alias') or i['thread_id']} {where} {i['kind']}: {i['reason']}{sched}\n {i['command']}"
|