|
1 | | -# PyAutoHeart — Agent Guidance |
| 1 | +# PyAutoHeart — Claude guidance |
2 | 2 |
|
3 | | -This file is for AI coding agents (Claude Code, Codex, Cursor, etc.) |
4 | | -discovering this repository. |
| 3 | +Read [`AGENTS.md`](AGENTS.md) in this directory. It is the shared source of |
| 4 | +truth for PyAutoHeart — the health authority of the PyAuto organism — and for |
| 5 | +the Brain / Heart / Build boundary. |
5 | 6 |
|
6 | | -## What this repo is |
7 | | - |
8 | | -PyAutoHeart is the **health and vital-signs authority** of the PyAuto organism. |
9 | | -It owns health and release-readiness checking: continuous monitoring (CI status, |
10 | | -dirty checkouts, branch ahead/behind, open PRs, worktree state, script-timing |
11 | | -regressions, version skew) plus deep on-demand/cloud checks (install |
12 | | -verification, URL hygiene), workspace validation, and generated-artifact/noise |
13 | | -classification, all green/yellow/red colour coded. `pyauto-heart readiness` is |
14 | | -the **authoritative** "is it safe to release?" gate. |
15 | | - |
16 | | -It is **separate** from PyAutoHands / PyAutoBuild on purpose: Hands is a pure |
17 | | -executor (it produces PyPI releases and runs no readiness checks); Heart owns |
18 | | -the checking. Heart shells out to `autobuild` primitives but never imports |
19 | | -PyAutoBuild Python, never writes into other repos, and never triggers Hands. |
20 | | - |
21 | | -See [`AGENTS.md`](AGENTS.md) for the canonical Brain/Heart/Hands boundary and |
22 | | -the `Brain → Heart → Hands` call chain, and `README.md` for user-facing docs. |
23 | | - |
24 | | -## Hard rules |
25 | | - |
26 | | -1. **Color coding everywhere**: green = passing, yellow = warning, |
27 | | - red = failing. Use the `c_ok / c_warn / c_fail / c_info / c_meta` |
28 | | - helpers in `heart/_color.sh` (bash) and `heart/heart_color.py` |
29 | | - (Python). Honour `NO_COLOR` and `--no-color`. |
30 | | -2. **Never write outside `~/.pyauto-heart/`** in any check module. |
31 | | - The daemon must be a pure observer; mutations belong in |
32 | | - `pyauto-heart fix <topic>` which only EMITS context for a fresh |
33 | | - Claude session. |
34 | | -3. **Polling must be cheap**. A full `tick` should complete in <30s |
35 | | - total. If a check would take longer, run it less often (move to a |
36 | | - v2 daily cron, not the watch loop). |
37 | | -4. **Lightweight test footprint**. Heart's own test suite runs on the |
38 | | - standard library plus PyYAML only — no scientific/ML stack (numba, |
39 | | - matplotlib, JAX, the PyAuto libraries). This keeps the suite fast and |
40 | | - flake-free so it runs anywhere (CI, mobile, sandbox). It is a property of |
41 | | - *Heart's* tests, not a claim about the projects Heart watches — Heart may |
42 | | - perfectly well monitor non-JAX (or JAX-heavy) repos; that's their concern, |
43 | | - not the suite's. |
44 | | -5. **State writes are atomic**. Use `heart.state.atomic_write_json` or |
45 | | - the bash equivalent (`heart_write_json` in `_common.sh`). Concurrent |
46 | | - ticks must not corrupt `state.json`. |
47 | | - |
48 | | -## Repo structure |
49 | | - |
50 | | -``` |
51 | | -bin/pyauto-heart # bash dispatcher |
52 | | -heart/ # all logic, shell-first |
53 | | - _color.sh, _common.sh |
54 | | - daemon.sh, tick.sh # the loop + one cycle |
55 | | - state.py, status.py, fix.py # Python side |
56 | | - heart_color.py |
57 | | - checks/ # one file per check class |
58 | | -config/repos.yaml # polled repo registry + thresholds |
59 | | -tests/ # pytest |
60 | | -``` |
61 | | - |
62 | | -## Adding a new check |
63 | | - |
64 | | -1. Create `heart/checks/<name>.{sh,py}` following the existing patterns. |
65 | | -2. Each check writes per-repo JSON sidecars to |
66 | | - `$HEART_PER_REPO_DIR/<repo>.<check_kind>.json` OR a global file at |
67 | | - `$HEART_STATE_DIR/<check_name>.json`. |
68 | | -3. Print a single colour-coded summary line to stdout (logged to the |
69 | | - daemon log by `heart_log`). |
70 | | -4. Add a section to `heart/status.py:render` that surfaces the result. |
71 | | -5. Add tests in `tests/test_<name>.py` covering classification edges. |
72 | | -6. Wire into `heart/tick.sh` in the appropriate position. |
73 | | - |
74 | | -## Running locally |
75 | | - |
76 | | -```bash |
77 | | -pip install -e .[dev] |
78 | | -pytest tests/ -v |
79 | | -HEART_FORCE_COLOR=1 pyauto-heart tick # one cycle, with colour |
80 | | -pyauto-heart status |
81 | | -``` |
82 | | - |
83 | | -## Codex / sandboxed runs |
84 | | - |
85 | | -```bash |
86 | | -NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib \ |
87 | | - pytest tests/ |
88 | | -``` |
89 | | - |
90 | | -## Never rewrite history |
91 | | - |
92 | | -NEVER perform these operations on any repo with a remote: |
93 | | - |
94 | | -- `git init` in a directory already tracked by git |
95 | | -- `rm -rf .git && git init` |
96 | | -- Commit with subject "Initial commit", "Fresh start", "Start fresh", |
97 | | - "Reset for AI workflow", or any equivalent message on a branch with |
98 | | - a remote |
99 | | -- `git push --force` to `main` |
100 | | -- `git filter-repo` / `git filter-branch` on shared branches |
101 | | -- `git rebase -i` rewriting commits already pushed to a shared branch |
102 | | - |
103 | | -If the working tree needs a clean state, the **only** correct sequence is: |
104 | | - |
105 | | - git fetch origin |
106 | | - git reset --hard origin/main |
107 | | - git clean -fd |
| 7 | +Internals (the check framework, the <30s tick budget, how to add a check, the |
| 8 | +hard rules) are in [`docs/internals.md`](docs/internals.md) — read it when |
| 9 | +working on Heart's own code, not by default. |
0 commit comments