Skip to content

Commit feb556c

Browse files
Jammy2211Jammy2211claude
authored
Stub CLAUDE.md; move internals to docs/internals.md (#33)
CLAUDE.md is auto-injected into agent context on first file read in this repo — at ~120 lines it was the largest involuntary context load in Heart. It is now a 9-line stub pointing at AGENTS.md (matching the PyAutoBrain pattern); the internals (check framework, tick budget, adding checks, hard rules) move to docs/internals.md, read on demand. The never-rewrite-history safety block moves to AGENTS.md so it stays in the always-read path. Co-authored-by: Jammy2211 <JNightingale2211@gmail.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent b07d80a commit feb556c

6 files changed

Lines changed: 107 additions & 111 deletions

File tree

AGENTS.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ Health Agent reasons over Heart's output, it does not re-derive it. Full detail
5252
- `readiness` rolls these into the authoritative verdict (URL hygiene is
5353
monitoring only and does **not** gate it).
5454

55-
See [`CLAUDE.md`](CLAUDE.md) for Heart's internals — the check framework, the
56-
<30s tick budget, how to add a check, and the hard rules (observer-only, colour
57-
coding, atomic state writes).
55+
See [`docs/internals.md`](docs/internals.md) for Heart's internals — the check
56+
framework, the <30s tick budget, how to add a check, and the hard rules
57+
(observer-only, colour coding, atomic state writes). Read it when changing
58+
Heart's own code, not by default.
59+
60+
## Never rewrite history
61+
62+
NEVER perform these operations on any repo with a remote:
63+
64+
- `git init` in a directory already tracked by git
65+
- `rm -rf .git && git init`
66+
- Commit with subject "Initial commit", "Fresh start", "Start fresh",
67+
"Reset for AI workflow", or any equivalent message on a branch with a remote
68+
- `git push --force` to `main`
69+
- `git filter-repo` / `git filter-branch` on shared branches
70+
- `git rebase -i` rewriting commits already pushed to a shared branch
71+
72+
If the working tree needs a clean state, the **only** correct sequence is:
73+
74+
git fetch origin
75+
git reset --hard origin/main
76+
git clean -fd

CLAUDE.md

Lines changed: 7 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,9 @@
1-
# PyAutoHeart — Agent Guidance
1+
# PyAutoHeart — Claude guidance
22

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.
56

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.

docs/internals.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# PyAutoHeart — internals
2+
3+
Operational detail for working **inside** this repo: the check framework, the
4+
tick budget, how to add a check, and the hard rules. What PyAutoHeart *is* and
5+
the Brain/Heart/Build boundary live in [`AGENTS.md`](../AGENTS.md) — read that
6+
first; read this only when changing Heart's own code.
7+
8+
## Hard rules
9+
10+
1. **Color coding everywhere**: green = passing, yellow = warning,
11+
red = failing. Use the `c_ok / c_warn / c_fail / c_info / c_meta`
12+
helpers in `heart/_color.sh` (bash) and `heart/heart_color.py`
13+
(Python). Honour `NO_COLOR` and `--no-color`.
14+
2. **Never write outside `~/.pyauto-heart/`** in any check module.
15+
The daemon must be a pure observer; mutations belong in
16+
`pyauto-heart fix <topic>` which only EMITS context for a fresh
17+
Claude session.
18+
3. **Polling must be cheap**. A full `tick` should complete in <30s
19+
total. If a check would take longer, run it less often (move to a
20+
v2 daily cron, not the watch loop).
21+
4. **Lightweight test footprint**. Heart's own test suite runs on the
22+
standard library plus PyYAML only — no scientific/ML stack (numba,
23+
matplotlib, JAX, the PyAuto libraries). This keeps the suite fast and
24+
flake-free so it runs anywhere (CI, mobile, sandbox). It is a property of
25+
*Heart's* tests, not a claim about the projects Heart watches — Heart may
26+
perfectly well monitor non-JAX (or JAX-heavy) repos; that's their concern,
27+
not the suite's.
28+
5. **State writes are atomic**. Use `heart.state.atomic_write_json` or
29+
the bash equivalent (`heart_write_json` in `_common.sh`). Concurrent
30+
ticks must not corrupt `state.json`.
31+
32+
## Repo structure
33+
34+
```
35+
bin/pyauto-heart # bash dispatcher
36+
heart/ # all logic, shell-first
37+
_color.sh, _common.sh
38+
daemon.sh, tick.sh # the loop + one cycle
39+
state.py, status.py, fix.py # Python side
40+
heart_color.py
41+
checks/ # one file per check class
42+
config/repos.yaml # polled repo registry + thresholds
43+
tests/ # pytest
44+
```
45+
46+
## Adding a new check
47+
48+
1. Create `heart/checks/<name>.{sh,py}` following the existing patterns.
49+
2. Each check writes per-repo JSON sidecars to
50+
`$HEART_PER_REPO_DIR/<repo>.<check_kind>.json` OR a global file at
51+
`$HEART_STATE_DIR/<check_name>.json`.
52+
3. Print a single colour-coded summary line to stdout (logged to the
53+
daemon log by `heart_log`).
54+
4. Add a section to `heart/status.py:render` that surfaces the result.
55+
5. Add tests in `tests/test_<name>.py` covering classification edges.
56+
6. Wire into `heart/tick.sh` in the appropriate position.
57+
58+
## Running locally
59+
60+
```bash
61+
pip install -e .[dev]
62+
pytest tests/ -v
63+
HEART_FORCE_COLOR=1 pyauto-heart tick # one cycle, with colour
64+
pyauto-heart status
65+
```
66+
67+
## Codex / sandboxed runs
68+
69+
```bash
70+
NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib \
71+
pytest tests/
72+
```
73+
74+
The never-rewrite-history rules live in [`AGENTS.md`](../AGENTS.md) and apply
75+
here as everywhere.

health_agent/capabilities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@ sidecars, rolling `timings/`, `url_check.json`, `verify_install.json`, daemon
9393
## Documentation describing health checks
9494

9595
`README.md` (user-facing), `AGENTS.md` (the Brain/Heart/Hands boundary + call
96-
chain), `CLAUDE.md` (internals: the check framework, the `<30s` tick budget, how
96+
chain), `docs/internals.md` (internals: the check framework, the `<30s` tick budget, how
9797
to add a check, the observer-only / colour / atomic-write hard rules).

health_agent/capabilities.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# treats Heart as an abstract health provider: when Heart gains or renames a
66
# check, update this manifest and the agent adapts without code changes.
77
#
8-
# Maintained alongside the checks. If you add a check (see CLAUDE.md "Adding a
8+
# Maintained alongside the checks. If you add a check (see docs/internals.md "Adding a
99
# new check"), add an entry here too.
1010

1111
provider:

heart/validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
Agent uploads/downloads this artifact and later feeds it to ``--ingest``
2525
alongside the ``commit_shas`` it read while orchestrating the build.
2626
27-
**Boundary (non-negotiable, mirrors CLAUDE.md).** This module NEVER dispatches
27+
**Boundary (non-negotiable, mirrors AGENTS.md).** This module NEVER dispatches
2828
a build, never talks to GitHub, never mutates any repo. All dispatching / polling
2929
/ artifact download is the Brain Release Agent's job; Heart is spec + ingest +
3030
verdict, credential-free. It writes ONLY under ``~/.pyauto-heart/`` (``--ingest``)

0 commit comments

Comments
 (0)