machina-cli 0.6.0__tar.gz → 0.6.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {machina_cli-0.6.0 → machina_cli-0.6.2}/CHANGELOG.md +10 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/PKG-INFO +1 -1
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs/harness-loop-kit/context-verify.py +74 -20
- {machina_cli-0.6.0 → machina_cli-0.6.2}/pyproject.toml +1 -1
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/__init__.py +1 -1
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/context_graph.py +5 -1
- {machina_cli-0.6.0 → machina_cli-0.6.2}/tests/test_context_graph_timeline.py +16 -2
- {machina_cli-0.6.0 → machina_cli-0.6.2}/.github/workflows/ci.yml +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/.github/workflows/release.yml +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/.gitignore +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/CLAUDE.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/README.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs/agentic-harness-loop.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs/credentials.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs/harness-loop-kit/PLAYBOOK-SCORECARD.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs/harness-loop-kit/README.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs/harness-loop-kit/VALIDATION.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs/harness-loop-kit/provision.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs/harness-loop-kit/surface-verify.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs/loop-tools-connector.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/.gitignore +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/.vitepress/config.mts +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/.vitepress/theme/custom.css +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/.vitepress/theme/index.ts +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/README.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/agent.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/config.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/connect.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/connector.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/context-graph.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/credentials.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/deploy.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/document.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/execution.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/factory.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/login.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/loop.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/mapping.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/mcp.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/org.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/project.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/prompt.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/skills.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/sports.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/template.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/update.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/commands/workflow.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/guide/authentication.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/guide/configuration.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/guide/installation.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/guide/quickstart.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/guide/repl.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/guide/running.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/index.md +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/package-lock.json +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/package.json +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/public/favicon.ico +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/public/machina-logo-dark.png +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/public/machina-logo-light.png +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/docs-site/vercel.json +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/install.ps1 +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/install.sh +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/browser_auth.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/client.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/__init__.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/agent.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/auth.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/config_cmd.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/connect.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/connector.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/credentials.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/deploy.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/document.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/execution.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/factory.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/loop.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/mapping.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/mcp.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/org.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/project.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/prompt.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/skills.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/sports.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/template.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/commands/workflow.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/config.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/factory_client.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/loop_client.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/main.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/models/__init__.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/project_client.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/repl.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/update_check.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/src/machina_cli/updater.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/tests/__init__.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/tests/test_cli_output.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/tests/test_connect.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/tests/test_mcp_url.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/tests/test_org_usage.py +0 -0
- {machina_cli-0.6.0 → machina_cli-0.6.2}/tests/test_sports_integration.py +0 -0
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to machina-cli are documented here.
|
|
4
4
|
|
|
5
|
+
## [0.6.2] - 2026-07-01
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **The analysis audit no longer alerts on — or heals — matches that were already played.** User question after the first live cycle: *why is it looking at these matches when the championship is paused?* Root cause: the scan audits the newest researched fixture documents with no notion of time, and during the World Cup pause those are all finished games — the first heal cycle re-researched 22 already-played Copa do Brasil/friendly fixtures (real cost, no reader: nobody reads a pre-match analysis for a finished match). Now `broken_edges` (the alerting/healing metric) covers only groups touching at least one not-yet-played fixture; fully-played groups are counted separately as `broken_played_edges` (archival integrity debt — reported in messages as a note, never paged, never healed). Heal dispatches exclude finished fixtures even in mixed groups; missing/unknown status still counts as relevant so a possibly-live page is never hidden.
|
|
9
|
+
|
|
10
|
+
## [0.6.1] - 2026-07-01
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **Slack + timeline messages now tell the whole incident, in plain language.** User feedback from the first live heal cycle: the recovered message said "Back to 0 broken (was 1)" after a 13→10→7→4→1→0 drain — the last reading, not the story — and neither message explained what the error *means* or how the fix works. The recovered message now walks the incident's history: "the incident peaked at 13; auto-heal re-researched 22 fixture(s) across 5 round(s) (fresh web search + AI extraction per fixture), no human needed." The detected message now opens with what users are actually seeing ("N match page(s) are showing a pre-match analysis that belongs to a DIFFERENT match") before the LLM's concrete example, and states how the heal works. `context-graph timeline`'s recovered event likewise reports the incident peak.
|
|
14
|
+
|
|
5
15
|
## [0.6.0] - 2026-07-01
|
|
6
16
|
|
|
7
17
|
### Added
|
|
@@ -242,8 +242,20 @@ def _pairing(v):
|
|
|
242
242
|
return o.get("home_team"), o.get("away_team")
|
|
243
243
|
return None, None
|
|
244
244
|
|
|
245
|
+
# A finished match's pre-match analysis is dead content: nobody reads it as a preview
|
|
246
|
+
# anymore, so a misattribution there is archival debt, not a live incident -- and
|
|
247
|
+
# re-researching it is pure cost. Learned live on SBOT Prd during the World Cup pause:
|
|
248
|
+
# the 500 newest researched fixtures were ALL closed (paused league), and the first heal
|
|
249
|
+
# cycle re-researched 22 already-played matches. Missing/unknown status counts as
|
|
250
|
+
# relevant (never hide a possibly-live page).
|
|
251
|
+
FINISHED_STATUSES = ("closed", "ended", "cancelled")
|
|
252
|
+
|
|
245
253
|
def scan_edges(request_data: dict) -> dict:
|
|
246
|
-
"""analysis <-> fixture: distinct matches can't share an identical pre-match analysis.
|
|
254
|
+
"""analysis <-> fixture: distinct matches can't share an identical pre-match analysis.
|
|
255
|
+
|
|
256
|
+
Alerting/healing metric (broken_edges) covers only groups touching at least one
|
|
257
|
+
not-yet-played fixture; groups made entirely of finished matches are counted
|
|
258
|
+
separately (broken_played_edges) -- real integrity debt, but no live page to fix."""
|
|
247
259
|
p = request_data.get("params", {}) or request_data
|
|
248
260
|
try: docs = _docs("sportradar-fixture", {"value.has_pre_match_research": True}, _limit(p))
|
|
249
261
|
except Exception as ex:
|
|
@@ -254,21 +266,30 @@ def scan_edges(request_data: dict) -> dict:
|
|
|
254
266
|
tf = (v.get("pre_match_research") or {}).get("team_form") or {}
|
|
255
267
|
ha = ((tf.get("home") or {}).get("analysis") or "").strip()
|
|
256
268
|
title = re.sub(r"\s*\(\d+\)\s*$", "", str(v.get("title") or "")).strip()
|
|
257
|
-
if ha and title:
|
|
258
|
-
|
|
259
|
-
|
|
269
|
+
if ha and title:
|
|
270
|
+
finished = str(v.get("status") or "").lower() in FINISHED_STATUSES
|
|
271
|
+
enriched.append((title, v.get("sport_event_id"), finished, re.sub(r"\s+", " ", ha.lower())[:160]))
|
|
272
|
+
groups = defaultdict(set); group_ids = defaultdict(set); group_live_ids = defaultdict(set)
|
|
273
|
+
for title, sid, finished, key in enriched:
|
|
260
274
|
groups[key].add(title)
|
|
261
|
-
if sid:
|
|
275
|
+
if sid:
|
|
276
|
+
group_ids[key].add(sid)
|
|
277
|
+
if not finished: group_live_ids[key].add(sid)
|
|
262
278
|
collapsed = {k: sorted(v) for k, v in groups.items() if len(v) > 1}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
279
|
+
live_groups = {k: v for k, v in collapsed.items() if group_live_ids.get(k)}
|
|
280
|
+
played_groups = {k: v for k, v in collapsed.items() if not group_live_ids.get(k)}
|
|
281
|
+
broken = sum(len(v) - 1 for v in live_groups.values())
|
|
282
|
+
broken_played = sum(len(v) - 1 for v in played_groups.values())
|
|
283
|
+
# fixture_ids feed the auto-heal: only the NOT-YET-PLAYED fixtures of live groups get
|
|
284
|
+
# re-researched (we can't tell which fixture rightfully owns the analysis, and
|
|
285
|
+
# re-researching a live owner is harmless -- but re-researching a finished match is
|
|
286
|
+
# cost with no reader).
|
|
287
|
+
flagged = [{"fixtures": v, "fixture_ids": sorted(group_live_ids.get(k, set())), "analysis": k[:120]}
|
|
288
|
+
for k, v in list(live_groups.items())[:10]]
|
|
269
289
|
n = len(enriched)
|
|
270
290
|
health = {"edge": "analysis<->fixture", "sampled": n, "collapsed_groups": len(collapsed),
|
|
271
|
-
"broken_edges": broken, "
|
|
291
|
+
"broken_edges": broken, "broken_played_edges": broken_played,
|
|
292
|
+
"broken_rate_pct": round(100 * broken / n) if n else 0}
|
|
272
293
|
return {"status": True, "data": {"health": health, "flagged": flagged, "heal_needed": broken > 0}}
|
|
273
294
|
|
|
274
295
|
def scan_odds(request_data: dict) -> dict:
|
|
@@ -517,19 +538,35 @@ def notify_slack(request_data: dict) -> dict:
|
|
|
517
538
|
# name then walk client-side to the first (most recent) match for THIS edge. This
|
|
518
539
|
# task runs before save-health persists the current run, so the first match found
|
|
519
540
|
# here is genuinely the prior reading -- same trick surface-verify uses.
|
|
541
|
+
# One history read serves both needs: the immediately-prior reading (transition
|
|
542
|
+
# detection) AND, on recovery, the whole incident's stats -- consecutive broken
|
|
543
|
+
# readings walking back from now (peak count, heal rounds, fixtures re-researched).
|
|
544
|
+
# Without the incident walk, the recovered message reports only the last reading
|
|
545
|
+
# ("was 1" after a 13->10->7->4->1 drain) and the story is invisible to the reader.
|
|
520
546
|
prev_count, prev_budget_exceeded = None, False
|
|
547
|
+
peak, healed_total, heal_rounds = 0, 0, 0
|
|
521
548
|
try:
|
|
522
549
|
from core.document.controller import document_search
|
|
523
|
-
r = document_search(filters={"name": "context_graph_health"}, page=1, page_size=
|
|
550
|
+
r = document_search(filters={"name": "context_graph_health"}, page=1, page_size=50,
|
|
524
551
|
sorters=["created", -1])
|
|
525
552
|
dd = r.get("data") if isinstance(r, dict) else None
|
|
526
553
|
rows = dd.get("data") if isinstance(dd, dict) else (dd if isinstance(dd, list) else [])
|
|
554
|
+
first = True
|
|
527
555
|
for row in rows or []:
|
|
528
556
|
rv = row.get("value") or {}
|
|
529
|
-
if (rv.get("health") or {}).get("edge")
|
|
557
|
+
if (rv.get("health") or {}).get("edge") != edge:
|
|
558
|
+
continue
|
|
559
|
+
b = (rv.get("health") or {}).get(count_field) or 0
|
|
560
|
+
if first:
|
|
530
561
|
prev_count = (rv.get("health") or {}).get(count_field)
|
|
531
562
|
prev_budget_exceeded = bool((rv.get("healed") or {}).get("budget_exceeded"))
|
|
532
|
-
|
|
563
|
+
first = False
|
|
564
|
+
if b <= 0:
|
|
565
|
+
break # incident start reached
|
|
566
|
+
peak = max(peak, b)
|
|
567
|
+
hc = (rv.get("healed") or {}).get("heal_count") or 0
|
|
568
|
+
if hc:
|
|
569
|
+
healed_total += hc; heal_rounds += 1
|
|
533
570
|
except Exception:
|
|
534
571
|
pass
|
|
535
572
|
|
|
@@ -545,6 +582,15 @@ def notify_slack(request_data: dict) -> dict:
|
|
|
545
582
|
if is_broken == was_broken and not newly_exhausted:
|
|
546
583
|
return {"status": True, "data": {"notified": False, "skipped": "unchanged"}}
|
|
547
584
|
|
|
585
|
+
# Plain-language meaning of a broken edge, so the reader doesn't need to know the
|
|
586
|
+
# edge taxonomy to understand what users are actually seeing.
|
|
587
|
+
meaning = {
|
|
588
|
+
"analysis<->fixture": "%s upcoming match page(s) are showing a pre-match analysis that belongs to a DIFFERENT match.",
|
|
589
|
+
"odd<->market<->fixture": "%s market(s) reference odds/options from the wrong fixture.",
|
|
590
|
+
}.get(edge, "%s record(s) are attributed to the wrong entity.")
|
|
591
|
+
played = health.get("broken_played_edges") or 0
|
|
592
|
+
played_note = (" (%s more on already-played matches -- archival debt, not healed)" % played) if played else ""
|
|
593
|
+
|
|
548
594
|
assessment = (p.get("assessment") or "").strip()
|
|
549
595
|
if is_broken and budget_exceeded:
|
|
550
596
|
headline = ":rotating_light: *Context Graph -- could NOT self-heal* (`%s`)" % edge
|
|
@@ -555,15 +601,23 @@ def notify_slack(request_data: dict) -> dict:
|
|
|
555
601
|
backlog = healed.get("backlog") or 0
|
|
556
602
|
tail = " (%d more queued for the next scans)" % backlog if backlog else ""
|
|
557
603
|
headline = ":adhesive_bandage: *Context Graph -- data issue found, self-healing* (`%s`)" % edge
|
|
558
|
-
body = (
|
|
559
|
-
("
|
|
604
|
+
body = (meaning % count) + played_note + \
|
|
605
|
+
(("\n>" + assessment) if assessment else "") + \
|
|
606
|
+
("\n>Auto-heal is re-researching each affected fixture (fresh web search + AI extraction "
|
|
607
|
+
"replaces the misattributed text) -- %d dispatched%s; the next scans verify." % (heal_count, tail))
|
|
560
608
|
elif is_broken:
|
|
561
609
|
headline = ":rotating_light: *Context Graph -- data issue found* (`%s`)" % edge
|
|
562
|
-
body =
|
|
563
|
-
|
|
610
|
+
body = (meaning % count) + played_note + \
|
|
611
|
+
(("\n>" + assessment) if assessment else "") + \
|
|
612
|
+
"\n>*Needs a human* -- auto-heal is not configured for this edge here."
|
|
564
613
|
else:
|
|
565
614
|
headline = ":white_check_mark: *Context Graph -- recovered* (`%s`)" % edge
|
|
566
|
-
|
|
615
|
+
if healed_total:
|
|
616
|
+
body = ("Back to 0 broken -- the incident peaked at %s; auto-heal re-researched %s fixture(s) "
|
|
617
|
+
"across %s round(s) (fresh web search + AI extraction per fixture), no human needed."
|
|
618
|
+
% (peak, healed_total, heal_rounds))
|
|
619
|
+
else:
|
|
620
|
+
body = "Back to 0 broken (incident peaked at %s)." % (peak or prev_count)
|
|
567
621
|
|
|
568
622
|
text = "%s\n>%s" % (headline, body)
|
|
569
623
|
body_bytes = json.dumps({"text": text}).encode()
|
|
@@ -215,7 +215,10 @@ def _events_from_history(health_docs: list, surface_docs: list) -> list:
|
|
|
215
215
|
for edge, rows in per_edge.items():
|
|
216
216
|
rows.sort(key=lambda r: r[0])
|
|
217
217
|
prev_broken = 0
|
|
218
|
+
peak = 0 # incident peak, so a drained recovery reads "peaked at 13", not "was 1"
|
|
218
219
|
for ts, broken, healed in rows:
|
|
220
|
+
if broken > 0:
|
|
221
|
+
peak = max(peak, broken)
|
|
219
222
|
if broken > 0 and prev_broken == 0:
|
|
220
223
|
events.append({"ts": ts, "edge": edge, "event": "detected", "detail": f"{broken} broken"})
|
|
221
224
|
if (healed.get("heal_count") or 0) > 0:
|
|
@@ -228,7 +231,8 @@ def _events_from_history(health_docs: list, surface_docs: list) -> list:
|
|
|
228
231
|
"detail": f"no progress after {healed.get('prior_attempts', '?')} rounds — needs a human"})
|
|
229
232
|
if broken == 0 and prev_broken > 0:
|
|
230
233
|
events.append({"ts": ts, "edge": edge, "event": "recovered",
|
|
231
|
-
"detail": f"back to 0 broken (
|
|
234
|
+
"detail": f"back to 0 broken (incident peaked at {peak})"})
|
|
235
|
+
peak = 0
|
|
232
236
|
prev_broken = broken
|
|
233
237
|
|
|
234
238
|
# live surface (surface<->users)
|
|
@@ -35,8 +35,9 @@ def test_detect_heal_recover_arc():
|
|
|
35
35
|
events = _events_from_history(docs, [])
|
|
36
36
|
kinds = [(e["event"], e["ts"].hour) for e in events]
|
|
37
37
|
assert kinds == [("detected", 11), ("heal", 11), ("heal", 12), ("recovered", 13)]
|
|
38
|
-
# recovery reports the
|
|
39
|
-
|
|
38
|
+
# recovery reports the incident PEAK (13), not the immediately-prior drained
|
|
39
|
+
# reading (7) — "was 1" after a 13->...->1 drain hides the story from the reader
|
|
40
|
+
assert "peaked at 13" in events[-1]["detail"]
|
|
40
41
|
assert "+1 queued" in events[1]["detail"]
|
|
41
42
|
|
|
42
43
|
|
|
@@ -83,6 +84,19 @@ def test_edges_are_isolated():
|
|
|
83
84
|
assert len(events) == 1 and events[0]["edge"] == "analysis<->fixture"
|
|
84
85
|
|
|
85
86
|
|
|
87
|
+
def test_second_incident_peak_does_not_inherit_the_first():
|
|
88
|
+
docs = [
|
|
89
|
+
_health_doc("Wed, 01 Jul 2026 10:00:00 GMT", "analysis<->fixture", 13),
|
|
90
|
+
_health_doc("Wed, 01 Jul 2026 11:00:00 GMT", "analysis<->fixture", 0),
|
|
91
|
+
_health_doc("Wed, 01 Jul 2026 12:00:00 GMT", "analysis<->fixture", 2),
|
|
92
|
+
_health_doc("Wed, 01 Jul 2026 13:00:00 GMT", "analysis<->fixture", 0),
|
|
93
|
+
]
|
|
94
|
+
events = _events_from_history(docs, [])
|
|
95
|
+
recoveries = [e for e in events if e["event"] == "recovered"]
|
|
96
|
+
assert "peaked at 13" in recoveries[0]["detail"]
|
|
97
|
+
assert "peaked at 2" in recoveries[1]["detail"]
|
|
98
|
+
|
|
99
|
+
|
|
86
100
|
def test_surface_transitions_and_heal():
|
|
87
101
|
docs = [
|
|
88
102
|
_surface_doc("Wed, 01 Jul 2026 10:00:00 GMT", "ok"),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|