Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions agents/conductors/health/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,22 @@ machine caller can tell "Heart says STALE" from "Heart unreachable" (`4`).
a later, explicitly-scoped follow-up.
- **Never escalate an unknown to GREEN or RED.** An unknown is YELLOW — surface
it, recommend the leg that resolves it, and checkpoint.

## Dashboard monitoring scope

`bin/pyauto-brain health --scope dashboard [--json] [assess|triage|recommend]`
reads Heart's dashboard inventory without ticking, dispatching or writing state.
The default scope remains `release`; `--scope release` makes it explicit.

Dashboard scope adopts `board.monitoring.status`, `score` and `complete` from
Heart, forwarding its checks, findings, applicability, evidence, penalties,
blocked reasons and action payloads unchanged. It uses the Heart CLI when
available and the existing published-board reader otherwise. Heart owns all
coverage judgments and remedies; the conductor presents them for review.

Re-read after the chosen action completes. Stop only when Heart reports a
complete green monitoring inventory with no unresolved findings. Release GREEN
alone never ends this loop. Missing, malformed or unsupported inventory is
explicitly unknown and incomplete (exit 4); an incomplete green inventory also
exits 4. Red/yellow/stale retain exits 3/2/6; grey exits 4. Completion exits 0.
The JSON retains `release_verdict` and `release_score` as separate context.
99 changes: 99 additions & 0 deletions agents/conductors/health/dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
"""Read Heart's monitoring inventory and forward its findings unchanged."""

import argparse
import json
import sys
from pathlib import Path


def assess(board):
monitoring = board.get("monitoring") if isinstance(board, dict) else None
error = None
if not isinstance(monitoring, dict):
error = "Heart monitoring inventory is missing."
elif not (
type(monitoring.get("schema_version")) is int
and monitoring.get("schema_version") == 1
and monitoring.get("status") in {"green", "red", "yellow", "stale", "grey"}
and type(monitoring.get("score")) is int
and type(monitoring.get("complete")) is bool
and isinstance(monitoring.get("counts"), dict)
and isinstance(monitoring.get("checks"), list)
and isinstance(monitoring.get("findings"), list)
and isinstance(monitoring.get("penalties"), list)
and all(isinstance(c, dict) for c in monitoring["checks"] + monitoring["findings"])
):
error = "Heart monitoring inventory is malformed or unsupported."
if error:
return {
"scope": "dashboard", "verdict": "unknown", "score": None,
"complete": False, "status": "unknown", "counts": {},
"checks": [], "findings": [], "items": [], "penalties": [],
"blocked_reason": error,
"recommendation": {"action": "blocked", "command": None,
"headline": error},
}
result = dict(monitoring)
# Status and completion are Heart-owned. Preserve all inventory fields,
# including applicability, evidence, blocked reasons and action payloads.
result.update(scope="dashboard", verdict=monitoring["status"],
items=monitoring["findings"],
release_verdict=board.get("verdict"),
release_score=board.get("score"))
findings = monitoring["findings"]
done = monitoring["complete"] and monitoring["status"] == "green" and not findings
first = findings[0] if findings else {}
action = first.get("action")
result["recommendation"] = {
"action": "none" if done else "review-findings" if findings else "blocked",
"command": action.get("payload") if isinstance(action, dict) and action.get("kind") == "command" else None,
"heart_action": action,
"headline": "Monitoring complete — no unresolved findings." if done else
first.get("summary") or "Monitoring incomplete — review Heart inventory coverage.",
"blocked_reason": first.get("blocked_reason"),
}
return result


def main():
parser = argparse.ArgumentParser()
parser.add_argument("--json", action="store_true")
parser.add_argument("--published", action="store_true")
parser.add_argument("--mode", choices=("assess", "triage", "recommend"), default="assess")
args = parser.parse_args()
try:
if args.published:
faculty = Path(__file__).resolve().parents[2] / "faculties" / "vitals"
sys.path.insert(0, str(faculty))
import _vitals
base, repo = _vitals.pages_source()
board = _vitals.read_published(base, repo)[1] if base else {}
else:
board = json.load(sys.stdin)
except Exception:
board = {}
result = assess(board)
if args.json:
print(json.dumps(result, indent=2))
else:
print("== health: dashboard monitoring = " + result["status"].upper() + " ==")
print("Monitoring score: " + str(result["score"]) + " · complete: " + str(result["complete"]))
if args.mode != "recommend":
for finding in result["findings"]:
print(" [" + str(finding.get("status", "unknown")) + "] " + str(finding.get("summary", "")))
action = finding.get("action")
if isinstance(action, dict):
print(" " + str(action.get("payload", "")))
if finding.get("blocked_reason"):
print(" Blocked: " + str(finding["blocked_reason"]))
print(result["recommendation"]["headline"])
if args.mode == "recommend" and result["recommendation"].get("heart_action"):
print(json.dumps(result["recommendation"]["heart_action"]))
print("Re-read with pyauto-brain health --scope dashboard; completion requires Heart's complete inventory and no unresolved findings.")
status = result["status"]
done = result["complete"] and status == "green" and not result["findings"]
return 0 if done else {"red": 3, "yellow": 2, "stale": 6}.get(status, 4)


if __name__ == "__main__":
sys.exit(main())
29 changes: 28 additions & 1 deletion agents/conductors/health/health.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
# health.sh assess # same as the no-arg assess
# health.sh triage # triage + recommend only (no card re-render)
# health.sh recommend # the single recommended next checkpoint only
# health.sh --scope dashboard [--json] [sub] # read-only monitoring inventory
# health.sh --scope release [--json] [sub] # default release readiness
# health.sh --json [sub] # machine footing for the Brain session
# health.sh -h|--help # this header
#
Expand All @@ -70,9 +72,14 @@ source "$HERE/../../_common.sh"
# ---------------------------------------------------------------------------
sub="assess"
json_only=0
for arg in "$@"; do
scope="release"
while [[ $# -gt 0 ]]; do
arg="$1"
shift
case "$arg" in
--json) json_only=1 ;;
--scope) scope="${1:-}"; [[ $# -gt 0 ]] && shift ;;
--scope=*) scope="${arg#--scope=}" ;;
-h|--help)
# Print only the comment header block (stop at the first non-comment line,
# so the help never bleeds into `set -uo pipefail` / `source ...`).
Expand All @@ -89,6 +96,26 @@ for arg in "$@"; do
esac
done

if [[ "$scope" != "release" && "$scope" != "dashboard" ]]; then
echo "health: scope must be release or dashboard" >&2
exit 5
fi

# Dashboard monitoring is a read-only Heart inventory, with its own completion
# contract. It never refreshes checks, dispatches actions, or consults release
# GREEN as a stopping condition.
if [[ "$scope" == "dashboard" ]]; then
dashboard_args=(--mode "$sub")
[[ "$json_only" -eq 1 ]] && dashboard_args+=(--json)
if heart="$(resolve_heart 2>/dev/null)"; then
bash "$(_agents_dir)/faculties/vitals/vitals.sh" dashboard --json 2>/dev/null |
python3 "$HERE/dashboard.py" "${dashboard_args[@]}"
exit $?
fi
python3 "$HERE/dashboard.py" --published "${dashboard_args[@]}"
exit $?
fi

# ---------------------------------------------------------------------------
# Locate the vitals faculty (the single component that talks to Heart) and the
# Heart capability manifest (Heart self-describing its surface — never vendored).
Expand Down
15 changes: 9 additions & 6 deletions agents/faculties/vitals/_vitals.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,19 @@ def read_published(pages_base, heart_repo):


def verdict_of(badge, board):
"""The organism-wide verdict word. The badge's `message` is the headline
contract every board publishes (`GREEN`, `RED 3 blockers`, ...); a board
that carries its own `verdict` is the fallback for a badge that did not
arrive."""
"""The explicit release verdict; older publishes fall back to the badge.

Current badges headline monitoring, which cannot stand in for a release
gate. Heart retains the release verdict in board.json.
"""
own = str((board or {}).get("verdict", "") or "").strip().upper()
if own in VERDICTS:
return own
message = str((badge or {}).get("message", "") or "").strip()
head = message.split()[0].upper() if message else ""
if head in VERDICTS:
return head
own = str((board or {}).get("verdict", "") or "").strip().upper()
return own if own in VERDICTS else "UNKNOWN"
return "UNKNOWN"


def board_timestamp(board):
Expand Down
6 changes: 4 additions & 2 deletions board/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ extra state: each render reads yesterday's page, appends today, caps at 30).

**Compose, don't recompute** — the board re-derives nothing. The community
section imports the community conductor's `build_scan()`; the resume counts
are parsed from the Mind's own generated `dashboard.md`; readiness comes from
the Heart board's published badge. Every unreachable source degrades into an
are parsed from the Mind's own generated `dashboard.md`; release readiness comes from
the Heart board's explicit `verdict` (older publishes fall back to the badge).
Monitoring headlines use Heart's `monitoring.score`, status and completion;
the published badge can describe monitoring independently of release readiness. Every unreachable source degrades into an
honest "Degraded" row, never fabricated content.

**Read-only** — the collect half touches only read-only `gh` endpoints and
Expand Down
18 changes: 18 additions & 0 deletions board/_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,11 @@ def collect():
# One read of the Heart's machine surface, two consumers: the blockers
# and the test-performance block.
heart_board = fetch_heart_board(pages_base, heart_repo, degraded)
# Badge headlines now describe monitoring; release labels and gates use
# Heart's explicit compatibility verdict from board.json.
if isinstance(heart_board, dict) and heart_board.get("verdict"):
heart = dict(heart or {})
heart["message"] = str(heart_board["verdict"]).upper()
heart_blockers = extract_heart_blockers(heart_board)
heart_plan = extract_heart_plan(heart_board)
performance = extract_heart_performance(
Expand All @@ -937,6 +942,7 @@ def collect():
"repo": board_family.get("brain", "PyAutoBrain"),
"overnight": overnight,
"heart": heart,
"heart_monitoring": (heart_board or {}).get("monitoring"),
"heart_blockers": heart_blockers,
"heart_plan": heart_plan,
"performance": performance,
Expand Down Expand Up @@ -1233,6 +1239,11 @@ def render_md(data):
L.append(f" - {r['blocked_reason']}")
L.append("")
L.append("## ❤️ Readiness & release")
monitoring = data.get("heart_monitoring")
if isinstance(monitoring, dict) and type(monitoring.get("score")) is int:
L.append(f"- Monitoring score: **{monitoring['score']}/100** — "
f"{monitoring.get('status', 'unknown')} · complete: "
f"{monitoring.get('complete', False)} · `pyauto-brain health --scope dashboard`")
if data["heart"]:
L.append(f"- Heart verdict: **{data['heart'].get('message', '?')}** — "
f"[board]({data['boards'].get('heart', '')}) · re-run via the health skill")
Expand Down Expand Up @@ -1556,6 +1567,13 @@ def render_html(data):
H.append(_plain(text))

H.append("<h2>❤️ Readiness &amp; release</h2>")
monitoring = data.get("heart_monitoring")
if isinstance(monitoring, dict) and type(monitoring.get("score")) is int:
H.append(_row(
"Monitoring score — " + _plain(str(monitoring["score"]) + "/100 · "
+ str(monitoring.get("status", "unknown")) + " · complete: "
+ str(monitoring.get("complete", False))),
"pyauto-brain health --scope dashboard"))
heart_url = data["boards"].get("heart", "")
if data["heart"]:
msg = data["heart"].get("message", "?")
Expand Down
19 changes: 19 additions & 0 deletions skills/health/health.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,22 @@ procedures are Heart's.
On the shell side, the same vocabulary applies: `health` (git-sync dashboard),
`health release`, and `health audit` (see `PyAutoHeart/scripts/health.sh`) — a
separate local convenience layer, not this command.

## Dashboard monitoring scope

`bin/pyauto-brain health --scope dashboard [--json] [assess|triage|recommend]`
reads Heart's dashboard inventory without ticking, dispatching or writing state.
The default scope remains `release`; `--scope release` makes it explicit.

Dashboard scope adopts `board.monitoring.status`, `score` and `complete` from
Heart, forwarding its checks, findings, applicability, evidence, penalties,
blocked reasons and action payloads unchanged. It uses the Heart CLI when
available and the existing published-board reader otherwise. Heart owns all
coverage judgments and remedies; the conductor presents them for review.

Re-read after the chosen action completes. Stop only when Heart reports a
complete green monitoring inventory with no unresolved findings. Release GREEN
alone never ends this loop. Missing, malformed or unsupported inventory is
explicitly unknown and incomplete (exit 4); an incomplete green inventory also
exits 4. Red/yellow/stale retain exits 3/2/6; grey exits 4. Completion exits 0.
The JSON retains `release_verdict` and `release_score` as separate context.
15 changes: 14 additions & 1 deletion tests/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

SURFACE_KEYS = {
"generated", "org", "repo", "overnight", "heart", "heart_blockers",
"heart_plan", "performance",
"heart_plan", "heart_monitoring", "performance",
"hands", "versions", "community", "resume", "open_issues", "hygiene",
"devbox", "autonomy", "doors", "boards", "degraded", "history",
# The science organ's own counts (its dashboard.md counts table), None
Expand Down Expand Up @@ -1094,3 +1094,16 @@ def test_legacy_copy_payload_is_portable_but_terminal_payload_is_unchanged():
page = b._row("Legacy", "/health Inspect <repo> & preserve edits")
assert 'data-cmd="Use the health skill. Inspect &lt;repo&gt; &amp; preserve edits"' in page
assert 'data-cmd="/health"' in b._row("Terminal", "/health", term=True)


def test_monitoring_headline_keeps_release_verdict_separate(tmp_path):
heart_board = {**HEART_BOARD_JSON, "verdict": "green",
"monitoring": {"score": 72, "status": "red", "complete": False}}
stub = _fabricate(tmp_path, _default_fixtures(), heart_board)
md = _run([], tmp_path, stub).stdout
assert "Monitoring score: **72/100**" in md
assert "Heart verdict: **GREEN**" in md
page = _run(["--html"], tmp_path, stub).stdout
assert "Monitoring score" in page
assert "72/100" in page
assert "pyauto-brain health --scope dashboard" in page
Loading
Loading