Skip to content

feat(board): publish state.json cockpit feed + transition-only ntfy alert (PyAutoBrain#416) - #238

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/organ-cockpit-state-feed
Sep 26, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/organ-cockpit-state-feed

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Summary

Organ cockpit phase 1, PR 2 of 2 (PyAutoBrain#416, after PyAutoBrain#417): the Heart publishes the shared state.json cockpit feed next to its badge.json/board.json, validates it in the board workflow against the Brain contract (PyAutoBrain/board/_state.py, checked out in the job already), and sends a transition-only push alert through ntfy when the readiness status changes (GREEN→RED, RED→GREEN, …). No alert on an unchanged status and none on the first run, since there is no previously published feed to compare with. The existing [heart-health] issue channel is untouched.

The previous status is read from the last published Pages feed (curl …/PyAutoHeart/state.json), so no new state is persisted anywhere. HEART_NTFY_URL (already set as a repo secret) points at a private ntfy topic; when unset the step prints a notice and skips.

API Changes

  • heart/dashboard.py: to_state(board), grey_state(), fmt == "state" and a --state CLI flag (no-snapshot fallback emits a valid grey feed, exit 0).
  • New heart/alert.py: transition(previous, new), render_message(kind, state), notify(url, …) and the CLI python -m heart.alert --previous prev.json --current state.json [--url] (always exit 0).
  • .github/workflows/heart-health.yml: render _site/state.json; "Validate the cockpit feed against the Brain contract" (fails the job on drift); "Push a transition alert" before the Pages upload.
    See full details below.

Test Plan

  • pytest tests/ — 1063 passed (test_alert.py new; 8 new to_state tests in test_dashboard.py)
  • Brain validator accepted the generated feed (red snapshot and grey no-snapshot): state: ok
  • Tenant firewall (organ code) OK on the worktree; workflow YAML parses
  • ntfy path verified by the human with a manual curl (phone + laptop received it)
  • After merge: next heart-health run publishes state.json (validate step green) and sends nothing (first run); the first later status change sends exactly one push
Full API Changes (for automation & release notes)

Added

  • heart/dashboard.py — STATE_SCHEMA_VERSION, STATE_STATUSES, _iso_z (board.ts → whole-second …Z, naive treated as UTC), _clip (160 chars), grey_state(), to_state(board) (verdict → status, unknown → grey; first red/yellow/stale reason or a "clear" line with the score → headline; blockers → items with run_url/repo_url + prompt, stale blockers → info; flat stale reasons only when no stale blocker exists), fmt="state", --state
  • heart/alert.py — transition (None/unknown previous or unknown new → None; stale↔green counts), render_message (Title Heart: GREEN -> RED — headers must be latin-1 — priority 5 for →red else 3, tags heart,<status>), notify/_post (stdlib urllib, never raises), CLI
  • tests/test_alert.py
  • workflow steps as above; header comment now names the ntfy POST as the one outbound side effect (the "no secret beyond GITHUB_TOKEN" line was already stale — HEART_TIMINGS_TOKEN)

Removed

  • none

Migration

  • none — additive

Heart RED override (development only)

Heart readiness is RED (score 5, snapshot 2026-09-26T11:02:36+00:00). Verbatim reason strings:

  • PyAutoNerves: 1 commit(s) behind origin
  • PyAutoFit: 2 commit(s) behind origin
  • release validation FAILED (stage integrate)

The first two are local-checkout staleness (fast-forwarded this session); the third is the pre-existing release-integrate failure, unrelated to this diff (dashboard/alert/workflow only). Branch gates passed as listed above.

Human authorization (live, this session, 2026-09-26, for PyAutoBrain#416, covering both PRs of the task): "ok merge the pr and contonue"

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

Jammy2211 and others added 2 commits September 26, 2026 12:03
… push alert

PyAutoBrain#416 PR 2 (Heart side):
- dashboard.to_state / --state: contract-v1 cockpit feed projected from the
  same Board as every other surface; ts normalised to ISO-8601 Z; missing
  snapshot or verdict yields a valid grey feed, never a default green.
- heart/alert.py: compare the previously published state.json with the new
  one and POST one ntfy message only when the status changed; unknown
  previous never alerts; never raises, always exits 0.
- heart-health.yml: render _site/state.json, validate it with the Brain's
  board/_state.py, push the transition alert (HEART_NTFY_URL secret).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…irewall)

PyAutoBrain#416: replace tenant literals (org, library name, Pages host) in
tests/test_alert.py and tests/test_dashboard.py with example.org / SomeLib.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit c67bca0 into main Sep 26, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the feature/organ-cockpit-state-feed branch September 26, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant