Skip to content

feat(board): organ cockpit p1 — state.json feed + Heart alert #416

Closed

Description

@Jammy2211

Overview

Every organ board is a static Pages page rebuilt by a daily cron, and the human manages the ecosystem from a pile of browser tabs with nothing directing attention to a RED Heart. Phase 1 of the organ cockpit adds the two layers everything later builds on: a shared machine-readable state.json feed per organ (contract + validator in the Brain, emitted by the Brain and Heart boards) and a transition-only push alert on the Heart board. Truth stays in GitHub; no server, no Electron. Epic: organ-cockpit (PyAutoMind draft filed 2026-09-26).

Brain, Heart and Hands already publish badge.json (the cross-board headline contract) and per-organ board.json of differing shapes; this task formalises a small common feed on top rather than replacing either.

Plan

  • Define a v1 state.json contract (organ, repo, status, headline, updated, pages_url, items with GitHub links) with a stdlib validator and fixtures in PyAutoBrain.
  • Brain board emits state.json next to badge.json/board.json on every publish.
  • Heart board emits state.json from its readiness verdict and validates it in the workflow using the checked-out Brain validator.
  • Heart workflow fetches the previously published feed and sends one ntfy push only when the status changes (GREEN→RED, RED→GREEN, …); no push when unchanged or on first run.
  • Unit tests pin the validator, both renderers and the alert transition logic.
  • Two PRs, one issue: PyAutoBrain first (contract), PyAutoHeart second (needs the validator on Brain main).
Detailed implementation plan

Affected Repositories

  • PyAutoBrain (primary)
  • PyAutoHeart

Branch Survey

Repository Current Branch Dirty?
./organs/PyAutoBrain main clean (claimed by eyes-organ-order and cosmos-web-ring-greeting; disjoint files → parallel worktree)
./organs/PyAutoHeart main (behind 1, ff) clean (claimed by eyes-organ-order; disjoint files → parallel worktree)

Suggested branch: feature/organ-cockpit-state-feed
Worktree: ~/Code/PyAutoLabs-wt/organ-cockpit-state-feed/

Implementation Steps — PR 1 (PyAutoBrain)

  1. board/state_schema.json — documented v1 contract:
    {"schema_version": 1, "organ": "heart", "repo": "PyAutoHeart", "status": "green|yellow|red|stale|grey", "headline": "<one line>", "updated": "<ISO-8601 UTC>", "pages_url": "https://pyautolabs.github.io/PyAutoHeart/", "items": [{"severity": "red|yellow|info", "text": "...", "url": "<GitHub link>", "prompt": "<optional copy-for-Claude payload>"}]}
  2. board/_state.py — stdlib only (no jsonschema dependency, matching _board.py): validate_state(obj) -> list[str] (empty = valid), build_state(...) helper, and a python board/_state.py <file|-> CLI exiting 1 on errors so any organ workflow can validate its emission.
  3. board/_board.py — render_state(data): map badge_color → status (red→red, orange→yellow, lightgrey→grey, brightgreen→green), headline(data), data["generated"] → updated, actionable rows (Heart blockers, overnight failures, community waits) → items. --apply writes state.json beside badge.json (the writer block near line 1689, print line updated); add a --state flag mirroring --badge.
  4. tests/fixtures/state/brain.json, tests/fixtures/state/heart.json; tests/test_state_feed.py — both fixtures validate; bad status / missing field / non-UTC stamp rejected; render_state on the test_board.py sample data validates.
  5. board/AGENTS.md — one paragraph naming state.json as the cockpit feed alongside badge.json. brain_board.yml unchanged (--apply --out _site already publishes the directory).

Implementation Steps — PR 2 (PyAutoHeart, after PR 1 merges)

  1. heart/dashboard.py — to_state(board) and fmt == "state" / --state flag: verdict → status, first red/yellow reason or "clear" → headline, board.ts → updated, board.blockers → items (run_url/repo_url, prompt). Workflow renders _site/state.json beside board.json and validates it with python PyAutoBrain/board/_state.py _site/state.json (Brain is already checked out in the job).
  2. heart/alert.py — pure transition(previous_status, new_status) -> str | None (only when changed) and notify(kind, state, url) POSTing to ntfy (Title/Priority/Tags headers, body = headline + items; Pushover deferred). CLI python -m heart.alert --previous prev.json --current _site/state.json, exit 0 always, prints alert: none or alert: green→red sent.
  3. .github/workflows/heart-health.yml — before "Upload Pages artifact": curl -fsS https://pyautolabs.github.io/PyAutoHeart/state.json -o prev.json || echo '{}' > prev.json, then the CLI with HEART_NTFY_URL from secrets (step prints a notice and skips when unset). First run = no alert; recovery (RED→GREEN) also notifies.
  4. tests/test_alert.py — GREEN→RED one POST; GREEN→GREEN zero; RED→GREEN one; missing previous zero; POST failure never raises (mock urlopen). tests/test_dashboard.py — to_state output satisfies the required-field/status rules (Heart tests do not import Brain).
  5. Human step: create the HEART_NTFY_URL repo secret and install ntfy on phone/laptop (recorded in the PR body).

Key Files

  • PyAutoBrain/board/_board.py — board collect + renders; gains render_state
  • PyAutoBrain/board/_state.py — new contract validator + CLI
  • PyAutoBrain/board/state_schema.json — new documented contract
  • PyAutoHeart/heart/dashboard.py — gains to_state
  • PyAutoHeart/heart/alert.py — new transition alert
  • PyAutoHeart/.github/workflows/heart-health.yml — emit, validate, alert steps

Verification

  • Brain: pytest tests/test_state_feed.py tests/test_board.py; board/board.sh --apply --out /tmp/x writes a state.json that passes python board/_state.py.
  • Heart: pytest tests/test_alert.py tests/test_dashboard.py; python -m heart.dashboard --cloud --state | python PyAutoBrain/board/_state.py -.
  • After merge + deploy: curl https://pyautolabs.github.io/{PyAutoBrain,PyAutoHeart}/state.json validate; a verdict flip produces exactly one ntfy push and the following unchanged run produces none (the prompt's Witness).

Original Prompt

Click to expand starting prompt

Organ cockpit phase 1: state.json feed schema and Heart transition alert

Type: feature
Target: PyAutoBrain
Repos:

  • PyAutoBrain
  • PyAutoHeart
    Difficulty: large
    Autonomy: safe
    Priority: high
    Status: formalised
    Consequence: notify
    Witness: PyAutoBrain ships schema/state_schema.json and a validator with a test over fixture feeds for Brain and Heart; the two board workflows publish state.json (curl of the Pages URL returns JSON that passes the validator after the next deploy); the Heart alert step is exercised by a unit test that feeds GREEN->RED and GREEN->GREEN state pairs and asserts one POST and zero POSTs respectively.
    Review-minutes: 0
    Unattended: ready
    Epic: organ-cockpit

Every organ dashboard is a static Pages HTML page regenerated by a daily cron. The human manages the ecosystem from those pages as a pile of browser tabs, and nothing directs attention to a RED Heart. Phase 1 of the organ cockpit adds the two layers everything later builds on, without moving truth off GitHub. This prompt covers the Brain and the Heart only; the other organs adopt the feed in follow-up prompts once the schema exists.

  1. A fixed state.json schema (organ, status colour, updated stamp, one-line headline, attention items each with a GitHub link) plus a validator, living in PyAutoBrain. The Brain board workflow (brain_board.yml) emits state.json next to its Pages board as the reference implementation, and the Heart board workflow (heart-health.yml) emits its own from the readiness verdict.
  2. A transition-only push alert on the PyAutoHeart board workflow: compare the new readiness verdict with the previous state and, only on a change such as GREEN to RED, POST to an ntfy or Pushover topic held in a repo secret.

Out of scope (later phases): the remaining organs emitting the feed (one small prompt each), the PWA cockpit page on pyautolabs.github.io reading all feeds with Heart pinned first, the start_dev Heart-RED gate, a tray-dot script, the Claude Code status line. No server, no Electron, no browser-side GitHub API reads.

Witness: PyAutoBrain ships schema/state_schema.json and a validator with a test over fixture feeds for Brain and Heart; the two board workflows publish state.json (curl of the Pages URL returns JSON that passes the validator after the next deploy); the Heart alert step is exercised by a unit test that feeds GREEN->RED and GREEN->GREEN state pairs and asserts one POST and zero POSTs respectively.

🤖 Generated with Claude Code

Activity

  1. Jammy2211 commented on Sep 26, 2026

    @Jammy2211
    ContributorAuthor

    Library PR created (PR 1 of 2) — under Heart RED override

    PR 1 (PyAutoBrain): #417 — state.json v1 contract, validator + CLI, Brain board emits state.json. 71 tests pass (23 new); live render validates; tenant firewall OK.

    PR 2 (PyAutoHeart) is committed on feature/organ-cockpit-state-feed in the task worktree (424d745 + 0c10d3f: to_state, heart/alert.py, workflow emit/validate/alert steps; 1063 tests pass) and opens after PR 1 merges, since its workflow validation step runs PyAutoBrain/board/_state.py from the checked-out Brain main. The HEART_NTFY_URL secret is already set on PyAutoHeart.

    Heart RED override (development only). Heart readiness RED (score 5, snapshot 2026-09-26T11:02:36+00:00); verbatim reasons:

    • 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 integrate failure, unrelated to board/. Human authorization, live, 2026-09-26, this session: "ok merge the pr and contonue".

  2. added a commit that references this issue on Sep 26, 2026
  3. Jammy2211 commented on Sep 26, 2026

    @Jammy2211
    ContributorAuthor

    PR 1 #417 merged (pytest 3.12/3.13 green; human merge command in session). PR 2 opened: PyAutoLabs/PyAutoHeart#238 (same RED override record in its body).

  4. Jammy2211 commented on Sep 26, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    • PR 1 PyAutoBrain#417 merged; PR 2 PyAutoHeart#238 merged (both pytest 3.12/3.13 green; human merge command in session under the recorded RED override).
    • Brain Board run 36238753173 and Heart Health run 36238726871 dispatched on main: both green. Heart's new steps: Validate the cockpit feed against the Brain contract → state: ok; Push a transition alert → alert: none (unknown→stale) (first run, no previously published feed — by design).
    • Published feeds validate with python board/_state.py:
    • HEART_NTFY_URL secret set; the human verified the ntfy path with a manual push. Witness leg still to be observed naturally: the first Heart status change after this run sends exactly one push, the following unchanged run none.

    Follow-ups (later phases, not filed yet): remaining organs emit state.json (one small prompt each — Mind, Cortex, Memory, Hands, Eyes, Gut, Nerves); PWA cockpit page on pyautolabs.github.io; start_dev Heart-RED gate; tray dot; Claude Code status line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions