diff --git a/.claude/commands/batch.md b/.claude/commands/batch.md new file mode 120000 index 00000000..6208c688 --- /dev/null +++ b/.claude/commands/batch.md @@ -0,0 +1 @@ +../../skills/batch/batch.md \ No newline at end of file diff --git a/.claude/commands/ci_speedup.md b/.claude/commands/ci_speedup.md new file mode 120000 index 00000000..3539bb31 --- /dev/null +++ b/.claude/commands/ci_speedup.md @@ -0,0 +1 @@ +../../skills/ci_speedup/ci_speedup.md \ No newline at end of file diff --git a/.claude/commands/register_and_iterate.md b/.claude/commands/register_and_iterate.md deleted file mode 120000 index e0d9e574..00000000 --- a/.claude/commands/register_and_iterate.md +++ /dev/null @@ -1 +0,0 @@ -../../skills/register_and_iterate/register_and_iterate.md \ No newline at end of file diff --git a/.claude/commands/run_queue.md b/.claude/commands/run_queue.md deleted file mode 120000 index 98080e98..00000000 --- a/.claude/commands/run_queue.md +++ /dev/null @@ -1 +0,0 @@ -../../skills/run_queue/run_queue.md \ No newline at end of file diff --git a/.claude/commands/start_bundle.md b/.claude/commands/start_bundle.md new file mode 120000 index 00000000..5b0ae3ae --- /dev/null +++ b/.claude/commands/start_bundle.md @@ -0,0 +1 @@ +../../skills/start_bundle/start_bundle.md \ No newline at end of file diff --git a/.claude/skills/batch b/.claude/skills/batch new file mode 120000 index 00000000..75eee06a --- /dev/null +++ b/.claude/skills/batch @@ -0,0 +1 @@ +../../skills/batch \ No newline at end of file diff --git a/.claude/skills/ci_speedup b/.claude/skills/ci_speedup new file mode 120000 index 00000000..98da2d02 --- /dev/null +++ b/.claude/skills/ci_speedup @@ -0,0 +1 @@ +../../skills/ci_speedup \ No newline at end of file diff --git a/.claude/skills/start_bundle b/.claude/skills/start_bundle new file mode 120000 index 00000000..52022188 --- /dev/null +++ b/.claude/skills/start_bundle @@ -0,0 +1 @@ +../../skills/start_bundle \ No newline at end of file diff --git a/.codex/skills/batch b/.codex/skills/batch new file mode 120000 index 00000000..75eee06a --- /dev/null +++ b/.codex/skills/batch @@ -0,0 +1 @@ +../../skills/batch \ No newline at end of file diff --git a/.codex/skills/ci-speedup b/.codex/skills/ci-speedup new file mode 120000 index 00000000..98da2d02 --- /dev/null +++ b/.codex/skills/ci-speedup @@ -0,0 +1 @@ +../../skills/ci_speedup \ No newline at end of file diff --git a/.codex/skills/register-and-iterate b/.codex/skills/register-and-iterate deleted file mode 120000 index 676dbdb0..00000000 --- a/.codex/skills/register-and-iterate +++ /dev/null @@ -1 +0,0 @@ -../../skills/register_and_iterate \ No newline at end of file diff --git a/.codex/skills/run-queue b/.codex/skills/run-queue deleted file mode 120000 index 15d64879..00000000 --- a/.codex/skills/run-queue +++ /dev/null @@ -1 +0,0 @@ -../../skills/run_queue \ No newline at end of file diff --git a/.codex/skills/start-bundle b/.codex/skills/start-bundle new file mode 120000 index 00000000..52022188 --- /dev/null +++ b/.codex/skills/start-bundle @@ -0,0 +1 @@ +../../skills/start_bundle \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f61e50ea..9ff09255 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -95,6 +95,25 @@ jobs: - name: Run tests working-directory: PyAutoBrain run: pytest tests/ -q + # The committed `.claude/` + `.codex/` discovery trees are generated + # symlinks, and nothing regenerated them: three skills (batch, + # ci_speedup, start_bundle) were never registered and two deleted ones + # (register_and_iterate, run_queue) stayed linked, so a web session — + # which loads only committed files — silently lacked those verbs. The + # generator has always had a drift mode; it just ran in no CI. Only the + # repos checked out above are examined (the check skips the rest), so + # this gates Brain and Mind and nothing a Brain PR cannot fix. + - name: Skill discovery trees are current (.claude/ + .codex/ symlinks) + run: bash PyAutoBrain/bin/install.sh --check-project-discovery + # A skill's SKILL.md + body is MANDATORY context every time the skill + # loads, so line count is a per-invocation token cost, not a style + # preference. Report-only: `batch` and `prm` are over the 200-line budget + # today and trimming them is its own task — this step makes the debt + # visible on every PR without reddening a gate nobody can currently pass. + - name: Skill line-count budget (report-only — known offenders) + continue-on-error: true + working-directory: PyAutoBrain + run: bash bin/check_skill_line_counts.sh - name: Tenant firewall (instance facts stay in declared config surfaces) run: > python3 PyAutoMind/scripts/repos_sync.py --check diff --git a/AGENTS.md b/AGENTS.md index e7eb9afd..4e822dfb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -141,7 +141,7 @@ the `/` slash commands. | `workspace` | The voice — the organism's expressive function: plan/survey workspace + HowTo example authorship (workspace\|howto registers) — WorkspaceDecision (never writes) | `bin/pyauto-brain workspace` | | `eyes` | The perceptive function — the organism's sense of its own appearance: survey/review a visualization workspace's figure surface, critiques route to intake/start_dev — EyesSurvey/EyesReviewSurface (never renders, never edits) | `bin/pyauto-brain eyes` | | `profiling` | The proprioceptive function — the organism's sense of its own effort: campaign/ingest/triage plans over the autolens_profiling workspace — ProfilingDecision | `bin/pyauto-brain profiling` | -| `cortex` | The learning function — where the organism keeps track of what is true: the per-project science ledger over PyAutoCortex ('cortex checkin') — pull every active project through its own sync CLI, show where each run stands, re-render the board; it records cluster facts and the human's words, never a verdict of its own | `bin/pyauto-brain cortex` | +| `cortex` | The learning function — where the organism keeps track of what is true: the per-project science ledger over PyAutoCortex — 'cortex pull' on the laptop pulls every active project through its own sync CLI and shows where each run stands; 'cortex checkin' anywhere stamps, re-renders the board and pushes the ledger; it records cluster facts and the human's words, never a verdict of its own | `bin/pyauto-brain cortex` | | `hygiene` | The maintenance function — the organism's sense of its own upkeep: code-quality debt (dev-loop cost + tidiness), delegating fixes — HygieneDecision | `bin/pyauto-brain hygiene` | | `clone` | The Mitosis Agent: partition the reference assistant, analyze the domain, emit the CloneDecision; --apply --mode lightweight-seed delegates the seed birth to Build; 'clone sync' patches the reference's generic-file diff onto the born siblings (dry run by default; rejected hunks are a human decision) | `bin/pyauto-brain clone` | | `build` | Coordinate execution: consult the vitals faculty, then delegate to PyAutoHands | `bin/pyauto-brain build` | @@ -166,48 +166,21 @@ it resolves the sibling `pyauto-heart` and `autohands` binaries from PATH or the ## Remote sessions (Claude Code on web and mobile) -Three facts, all measured in a web/mobile container, where this file is loaded -and little else is. They ride in every organ because a session may hold any -subset of them — and the session that needs this most is the one holding -several, which is exactly the session no hook fires in. +Three facts, measured in a web/mobile container. A session holding several +organs is cwd'd at the repos' *parent*, where no project hook fires, so +nothing has set it up — this block is what does. - **Bootstrap in the first turn, unconditionally** — before the first test - command, not as a remedy once something looks wrong: - - ``` - bash PyAutoMind/scripts/session_bootstrap.sh # ~10s cold, ~1s warm - bash PyAutoMind/scripts/session_bootstrap.sh --check # report only - ``` - - A session holding several organs registers no SessionStart hook — Claude Code - reads project hooks from the project directory, which in that layout is the - repos' *parent*, not a repo — so nothing has set this session up. It was once - phrased as a remedy keyed to `No module named pytest` or collection - `ImportError`s naming `yaml`; that symptom stopped appearing when the - container image moved to Python 3.12, while the environment is still wrong in - ways that read like a bad command rather than a stale session (`pytest -n - auto` → `unrecognized arguments: -n`). The bootstrap also **unshallows the - clones**: a remote session clones shallow, and `git merge-base --is-ancestor` - then answers "not an ancestor" for a commit whose ancestry is merely absent — - the answer the ship and close-out procedures act on when proving a branch - merged. - -- **Then run the suite in parallel.** 4 cores, subprocess-heavy suites, no - single slow test: about 3.5x. `python3 -m pytest -q -n auto`, with - `pytest-xdist` supplied by the bootstrap above. - -- **There is no `gh`, and installing one does not help.** A remote session - reaches GitHub through the `mcp__github__*` tools, already scoped to the - session's repos. `gh` installs in two seconds and is a trap: it authenticates, - then 403s every repo-scoped call, because the egress proxy serves neither the - REST repo paths nor GraphQL beyond a pinned set of PR-review operations — a - binary that looks healthy and fails everything that matters. It also defeats - the surface probe, which keys off `gh auth status`. Read - `PyAutoBrain/skills/GITHUB_ACCESS.md` at the top of any run that touches - GitHub; it maps each `gh` operation onto its MCP tool. Spell that path from - the workspace root, as written: a multi-organ session is cwd'd at the repos' - *parent*, so a bare `skills/…` reads as a missing file rather than a missing - repo prefix. + command, not as a remedy: `bash PyAutoMind/scripts/session_bootstrap.sh` + (`--check` reports only). It supplies pytest/PyYAML/xdist and **unshallows + the clones**, without which `git merge-base --is-ancestor` calls a merged + branch "not an ancestor" and the close-out acts on it. +- **Run the suite in parallel**: `python3 -m pytest -q -n auto` (4 cores, + ~3.5x). +- **There is no `gh`, and installing one does not help** — it authenticates, + then 403s every repo-scoped call through the egress proxy. GitHub is the + `mcp__github__*` tools; `PyAutoBrain/skills/GITHUB_ACCESS.md` maps each + `gh` operation onto its tool and is the one full page on the subject. ## The command surface (Brain implicit) diff --git a/ORGANISM.md b/ORGANISM.md index 0f909bb4..3253f6a9 100644 --- a/ORGANISM.md +++ b/ORGANISM.md @@ -14,7 +14,7 @@ organs plan, build, test and release it, and you make every judgment call. |-------|------|-------------------| | **Brain** | PyAutoBrain | Figures out *how* — reasoning, planning, decomposition, routing; hosts the specialist agents. Owns **no state, no health checks, no execution mechanics**. | | **Mind** | PyAutoMind | Decides *what* — intent, goals, priorities, workflow state, the prompt registry and taxonomy. Also holds the body map (`repos.yaml`, the single source of repo identity). | -| **Cortex** | PyAutoCortex | Learns *what is true* — the science body map (`projects.yaml`) and the rulings of record for every science run; the science mirror of the Mind (runs and rulings ↔ prompts and PRs). The Mind decides what to build, the Brain routes the work and executes nothing, the Cortex learns what is true. A verdict recorded only outside the Cortex does not exist: project ledgers are commentary that cite the ruling. | +| **Cortex** | PyAutoCortex | Keeps track of *what is true* — the science body map (`projects.yaml`) and **one ledger per science project** (`## Now`, the `## Runs` on the cluster, a `## Log` that only gets longer); the science mirror of the Mind (runs and a dated log ↔ prompts and PRs). Not a task tracker: it records cluster facts and the human's words, never a verdict of its own. | | **Memory** | PyAutoMemory | Long-term knowledge — *what the science says* (literature wikis, concepts, bibliographies). Operational history — *what the organism did* — lives in Mind (the `complete/` records, issues), not here. | | **Heart** | PyAutoHeart | Determines whether the organism is healthy. `pyauto-heart readiness` is the **authoritative** GREEN/YELLOW/RED "is it safe to release?" gate. An observer: never writes into other repos, never triggers Build. | | **Hands** | PyAutoHands | Builds and releases — packaging, tagging, notebook generation, PyPI via `release.yml`. A pure executor: runs no readiness checks and never re-derives a gate decision. | @@ -69,9 +69,9 @@ install wiring, a body-map row and boundary prose — it must earn that by owning state or effects no existing organ can. Two capabilities have earned organ status that way. Configuration/signalling is the **Nerves** (PyAutoNerves), the base config/serialization layer every library imports — new -config surfaces belong there, not in a new organ. Learning what is true is the -**Cortex** (PyAutoCortex), the second organ to earn it: it owns state no organ -owned before — the science body map and the rulings of record — so science -runs and their verdicts belong there, not in the Mind. The human interaction -layer is the command surface (`/route` + the verb commands), which is part of -Brain. +config surfaces belong there, not in a new organ. Keeping track of what is +true is the **Cortex** (PyAutoCortex), the second organ to earn it: it owns +state no organ owned before — the science body map and the per-project +ledgers — so science runs and the human's notes on them belong there, not in +the Mind. The human interaction layer is the command surface (`/route` + the +verb commands), which is part of Brain. diff --git a/README.md b/README.md index c503753b..9d5922dd 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ fresh when you wake. You drive it in plain English, through short slash commands in a Claude Code chat: `/intake` to file an idea, `/start_dev` to begin a task, `/health` for a check-up — or just `/route ` and the Brain picks the right -door. The full command surface (13 conductors + 5 faculties) is the generated -table in [AGENTS.md](AGENTS.md). +door. The generated table in [AGENTS.md](AGENTS.md) is the roster — every +conductor and faculty, regenerated from the router. 1. **A task arrives.** Usually from the Mind's backlog — pick a task on the [PyAutoMind dashboard](https://pyautolabs.github.io/PyAutoMind/) and paste @@ -43,7 +43,7 @@ table in [AGENTS.md](AGENTS.md). knows, `review` judges a branch. A conductor never consults another conductor — an opinion worth sharing becomes a faculty. 4. **The organs execute.** Always in the same order — **Brain → Heart (gate) - → Hands (execute)**: work happens on task worktrees, ships as pull + → Build (execute)**: work happens on task worktrees, ships as pull requests behind the Heart's health verdict, and is packaged and released by the Hands. 5. **Autonomy is a contract.** How much a run may do without a human is diff --git a/agents/conductors/cortex/AGENTS.md b/agents/conductors/cortex/AGENTS.md index f46780d8..88c2e333 100644 --- a/agents/conductors/cortex/AGENTS.md +++ b/agents/conductors/cortex/AGENTS.md @@ -3,14 +3,15 @@ > **Tier: conductor** — a front-door agent you *drive*. The *learning > function* — where the organism keeps track of what is true: it reasons over > PyAutoCortex (the science body map and **one ledger per project**) and -> answers one question — *where is my science?* — with one command, -> `checkin`: pull every active project through its own sync CLI, show where -> each run stands, re-render the board, push the ledger, read it back by -> project. It **records cluster facts and the human's words, never a verdict -> of its own**: it never scores a result, never drafts a ruling, never writes -> a `result` or `lesson` entry the human did not say. A run is submitted only -> on the human's ask (by the agent in the session, through the project's own -> sync CLI), and every ledger write is a `scripts/cortex.py` verb. +> answers one question — *where is my science?* — in two verbs, split where +> the machines split: `pull` asks the cluster (the laptop only, because every +> science root is a laptop path), `checkin` stamps, re-renders and pushes the +> board and reads the ledger back by project (anywhere). It **records cluster +> facts and the human's words, never a verdict of its own**: it never scores +> a result, never drafts a ruling, never writes a `result` or `lesson` entry +> the human did not say. A run is submitted only on the human's ask (by the +> agent in the session, through the project's own sync CLI), and every ledger +> write is a `scripts/cortex.py` verb. The same split the organism already uses twice — **Heart ↔ vitals**, **Gut ↔ hygiene**: the organ keeps the state, the conductor reasons over it. A ledger @@ -24,15 +25,18 @@ note`). | Verb | Question | Emits | |------|----------|-------| -| `checkin [--dry-run \| --apply] [--push \| --no-push] [--project KEY] [--skip-pull]` | **Where is my science?** | the door — the sequence below, ending in a summary keyed by project; exit **1** when a pull failed or the tree does not check | +| `pull [--project KEY] [--dry-run]` | **What does the cluster say?** | the laptop leg: each project's own ` pull`, streamed, then its `jobs` output verbatim, then one line per project (and the roots that are not on this machine, as skipped). Writes nothing. Exit **1** a pull failed · **2** no project's `local_path` is here | +| `checkin [--dry-run \| --apply] [--push \| --no-push] [--project KEY]` | **Where is my science?** | the door — the sequence below, ending in a summary keyed by project; reaches no cluster; exit **1** when the tree does not check | | `census [--json]` | What is the Cortex holding? | per project: status, summary, runs by state, log length, last update; totals (active projects, runs open, runs running); the check-in stamp; the problems `cortex.py check` would report | | `dashboard --check` | Are the committed pages current? | exit 0 current · **1 stale** · 2 no checkout · 3 unreadable tree | | `dashboard --apply` | — | writes `dashboard.md` + `dashboard.html` | | `issue [--project KEY] [--apply]` | What sits at the top of each project's issue? | the fenced ledger block (`cortex.py`'s `issue_block`) per project with an `Issue:`; `--apply` writes it into the issue body through `gh` (replacing the block between the markers, or prepending it); never creates an issue; exit **1** without `gh` | ``` -pyauto-brain cortex checkin --dry-run # what it would pull; reaches nothing -pyauto-brain cortex checkin --apply # the check-in +pyauto-brain cortex pull # the laptop: pull, then jobs verbatim +pyauto-brain cortex pull --dry-run # what it would pull; reaches nothing +pyauto-brain cortex checkin --dry-run # what it would write; writes nothing +pyauto-brain cortex checkin --apply # the check-in, on any surface pyauto-brain cortex # census pyauto-brain cortex dashboard --apply pyauto-brain cortex issue --apply @@ -70,7 +74,9 @@ Mind's: a session holding one organ and not the other still works. The page opens on the door: a counts table (`Running`, `Open`, `Projects` — what `board/_board.py` reads for the Brain board's Cortex strip), the -**check-in chip** — the paste for the laptop's science chat — and the **last +**check-in chip** — two lines, because the check-in has two halves that do +not run on the same machine: `pyauto-brain cortex pull` on the laptop, then +`pyauto-brain cortex checkin --apply --push` anywhere — and the **last check-in** stamp under it. Then **Summary**: one row per active project, four narrow columns (`Project | Running | Open | Last update`) so it fits a phone. Then **Projects**: a `### — ` card per project with a ledger — @@ -96,38 +102,58 @@ its age on the **viewer's** clock and reddens it once stale. `--check` compares the pages with the generation comment **and** the visible `Last updated` banner stripped, so a re-render on a new date is not drift. -## The door (`checkin`) - -The verb a human types. It composes what is already here and reasons nothing -of its own: - -1. **Sync.** Every project with `status: active` in `projects.yaml`, plus any - project whose ledger lists a run (a dormant project with a job still out - there is still out there). Each is pulled with **its own** - `/ pull`, output **streamed**, not captured. A - non-zero exit is recorded against that project and the sweep continues. -2. **Jobs.** Where the row has a `jobs` verb and the ledger lists runs, the +## The split: `pull` on the laptop, `checkin` anywhere + +Both verbs sweep the same set — every `status: active` row of +`projects.yaml`, plus any project whose ledger lists a run (a dormant project +with a job still out there is still out there) — and `--project KEY` narrows +either. What separates them is a fact about paths: a project's `local_path` +is a laptop path out of `projects.yaml`, so only the laptop can run its sync +CLI, while stamping, rendering, pushing and reading a ledger back work on any +surface. `checkin` used to do both, which made the headline verb a dry run +everywhere but one machine. + +### `pull` — the laptop leg + +1. **Roots first.** Every swept project's `local_path` is checked before + anything runs. None here → exit **2**, one line per project naming the + missing root and *"this is not the laptop — run `checkin` here and `pull` + on the laptop"*. Some here → those are pulled and the rest are listed as + skipped. +2. **Pull.** Each project's own `/ pull`, **streamed**, + not captured. A non-zero exit is recorded against that project, the sweep + continues, and the verb exits **1**. +3. **Jobs.** Where the row has a `jobs` verb and the ledger lists runs, the project's own ` jobs` is run and its output printed **verbatim** — no parsing, no state flip. The human, or the agent in the session, records what it says with `cortex.py running | done`. -3. **Stamp + render.** `checkin.yaml`, then `dashboard.md` + `dashboard.html`. -4. **Push** (the rule below). -5. **Summarise, by project** — printed **last**, so a chat sees it above the - fold: `key — summary`, what the pull did, the jobs output (or "no jobs - verb"), Now, the runs, the last five entries, and a fenced block of the - three `cortex.py` lines most likely typed next (`done`, `log --kind - result|lesson`, `now`). - -`--dry-run` (the default) prints the exact `cd && -pull` per project and reaches nothing at all. `--project KEY` narrows the -sweep; `--skip-pull` skips the pull and still asks `jobs`, stamps and renders. + +It writes nothing: no stamp, no pages, no ledger. `--dry-run` prints the exact +`cd && pull` per project and reaches nothing at all. + +### `checkin` — the door + +1. **Stamp + render.** `checkin.yaml`, then `dashboard.md` + `dashboard.html`. +2. **Push** (the rule below). +3. **Summarise, by project** — printed **last**, so a chat sees it above the + fold: `key — summary`, Now, the runs **as the ledger holds them**, the last + five entries, and a fenced block of the three `cortex.py` lines most likely + typed next (`done`, `log --kind result|lesson`, `now`). It closes by saying + those runs are the ledger's word, not the cluster's. + +It shells out to no sync CLI at all. `--dry-run` (the default) names what it +would write and writes nothing; `--skip-pull` is accepted and ignored with a +notice, so an old paste still runs. ### The push rule -`--push` is allowed only when **`gh auth status` succeeds** *and* **the Cortex -checkout is clean on `main`** — read *before* anything is written. That is the -whole cloud/laptop split, and it is also the default: a laptop pushes without -asking, a cloud session cannot and says so. The push cuts +`--push` is allowed when **the Cortex checkout is clean on `main` with a +resolvable `origin`** — read *before* anything is written — and it is the +default. It is git's own answer, asked of git alone: the leg that used to open +with `gh auth status` refused every surface that reaches GitHub another way, +which is how a quarter of the Cortex's commits came to be the merge bot +compensating. The push itself is the real gate — it succeeds, or the summary +says exactly how it failed. The push cuts `claude/checkin-` from a fresh `origin/main`, commits the changed paths **explicitly**, pushes, and names `ledger_merge.yml` as what lands it. `scripts/ledger_merge.py classify` is asked first and a code-classified diff is diff --git a/agents/conductors/cortex/_cortex.py b/agents/conductors/cortex/_cortex.py index cf1084a6..9178b301 100644 --- a/agents/conductors/cortex/_cortex.py +++ b/agents/conductors/cortex/_cortex.py @@ -6,9 +6,10 @@ The Cortex is **one ledger per science project** (`projects/.md`): a `## Now` the human rewrites, the `## Runs` on the cluster right now, and a dated `## Log`, newest first. This conductor renders that ledger as the -board, pulls every active project through its own sync CLI, shows where each -run stands, and reads the ledger back by project. It **records cluster facts -and the human's words, never a verdict of its own**: it never scores a +board, reads the ledger back by project, and — on the laptop, where the +science actually lives — pulls every active project through its own sync CLI +and shows where each run stands. It **records cluster facts and the human's +words, never a verdict of its own**: it never scores a result, never drafts a ruling, never writes a `result` or `lesson` entry — those are the human's words, written on their ask through the Cortex's own `scripts/cortex.py`. The same split as Heart ↔ vitals and Gut ↔ hygiene. @@ -26,13 +27,19 @@ the one place that carries such a path is the Cortex's own `projects.yaml`, and every path this module prints is read from a row of it at runtime. -Verbs: `checkin [--dry-run|--apply] [--push|--no-push] [--project KEY] -[--skip-pull]` (the door) · `census [--json]` · `dashboard --check|--apply` · -`issue [--project KEY] [--apply]`. +The verbs split along the one line the surfaces actually draw: a science +project's `local_path` is a laptop path, so only the laptop can pull it, +while stamping and rendering the board work anywhere. + +Verbs: `pull [--project KEY] [--dry-run]` (the laptop leg) · `checkin +[--dry-run|--apply] [--push|--no-push] [--project KEY]` (the door, reaches no +cluster) · `census [--json]` · `dashboard --check|--apply` · `issue +[--project KEY] [--apply]`. Exit codes: 0 ok · 1 dashboard drift (the `dashboard_refresh.yml` contract), a failed pull, or a tree that does not check · 2 bad args / no Cortex -checkout · 3 the Cortex tree could not be read. +checkout / no project's `local_path` is on this machine · 3 the Cortex tree +could not be read. """ from __future__ import annotations @@ -386,11 +393,18 @@ def _board_links(home: str, current: str) -> list: def checkin_payload(c: dict) -> str: - return (f"/cortex — check in on every active science project since the " - f"last check-in ({c.get('checkin') or CHECKIN_NEVER}): pull each " - "through its sync CLI, show me where each run stands, re-render " - "and push the board, then read me the by-project summary. Record " - "nothing about results — I will tell you what to log.") + """Two lines, because the check-in has two halves and they do not run on + the same machine: the pull needs the laptop the science lives on, the + check-in itself runs on whatever surface you are holding.""" + return "\n".join([ + "/cortex — on the laptop: `pyauto-brain cortex pull` — pull every " + "active science project through its own sync CLI and show me where " + "each run stands.", + f"/cortex — anywhere: `pyauto-brain cortex checkin --apply --push` — " + f"stamp, re-render and push the board since the last check-in " + f"({c.get('checkin') or CHECKIN_NEVER}), then read me the by-project " + "summary. Record nothing about results — I will tell you what to log.", + ]) def resume_payload(key: str, row: dict) -> str: @@ -756,6 +770,32 @@ def run_pull_streamed(projects: dict, keys: list) -> dict: return results +#: What a surface without the science on it is told, once, instead of seven +#: failed pulls: the split this module is built around. +NOT_THE_LAPTOP = ("this is not the laptop — run `checkin` here and `pull` on " + "the laptop") + + +def local_root(row: dict) -> str: + return (row.get("local_path") or "").strip() + + +def _root_of(projects: dict, key: str) -> str: + """A project's `local_path` as a line names it, or why there is none.""" + return local_root(projects.get(key, {})) or "(no local_path in projects.yaml)" + + +def split_by_root(projects: dict, keys: list) -> tuple: + """`(present, missing)` — which of `keys` have their `local_path` on this + machine. The one question that decides whether a pull can happen at all: + a project's root is a laptop path, and nothing else can stand in for it.""" + present, missing = [], [] + for key in keys: + root = local_root(projects.get(key, {})) + (present if root and Path(root).is_dir() else missing).append(key) + return present, missing + + def run_jobs(row: dict) -> str | None: """The project's own ` jobs`, verbatim — stdout and stderr as they came, no parsing. None when the row has no `jobs` verb.""" @@ -777,8 +817,8 @@ def run_jobs(row: dict) -> str | None: CHECKIN_BRANCH_PREFIX = "claude/checkin-" #: The rule the `--push` default resolves by, stated wherever it is applied. -PUSH_RULE = ("`--push` needs `gh auth status` to succeed and the Cortex " - "checkout to be clean on `main`") +PUSH_RULE = ("`--push` needs the Cortex checkout clean on `main` with a " + "resolvable `origin`") def _git(root: Path, *args: str) -> subprocess.CompletedProcess: @@ -788,23 +828,30 @@ def _git(root: Path, *args: str) -> subprocess.CompletedProcess: def push_preflight(root: Path) -> tuple: """`(ok, reason)` — may this check-in push its own ledger diff? Read - **before** anything is written. Two legs, both facts about this machine: - a logged-in `gh` (the cloud/laptop split) and a clean checkout on `main`.""" - if shutil.which("gh") is None: - return False, "no `gh` on PATH — this is not a laptop session" - if subprocess.run(["gh", "auth", "status"], capture_output=True, - text=True).returncode != 0: - return False, "`gh auth status` fails — not authenticated" + **before** anything is written, and asked of **git alone**. + + It used to open with a `gh` probe standing in for "this is a laptop". + That reading is wrong twice over: a session can push a branch without + `gh` (git credentials are not the GitHub CLI), and making the headline + verb refuse everywhere `gh` is absent is what left the ledger to the + merge bot. So the preflight asks only what git can answer — a checkout, + on `main`, clean, with an `origin` to push to — and the push itself is + the real gate: it either succeeds or `push_ledger` says exactly how it + failed. + """ head = _git(root, "rev-parse", "--abbrev-ref", "HEAD") if head.returncode != 0: return False, "the Cortex checkout is not a git repo" branch = head.stdout.strip() if branch != "main": return False, f"the Cortex checkout is on `{branch}`, not `main`" + origin = _git(root, "remote", "get-url", "origin") + if origin.returncode != 0 or not origin.stdout.strip(): + return False, "the Cortex checkout has no `origin` to push to" dirty = _git(root, "status", "--porcelain") if dirty.returncode != 0 or dirty.stdout.strip(): return False, "the Cortex checkout has uncommitted changes" - return True, "`gh` is authenticated and the Cortex is clean on `main`" + return True, "the Cortex is clean on `main` with an `origin`" def dirty_paths(root: Path) -> list[str]: @@ -921,24 +968,17 @@ def next_commands(key: str, d: dict | None) -> str: f'python3 scripts/cortex.py now {key} ""']) -def project_digest(key: str, c: dict, pull: tuple | None, jobs: str | None, - skipped: bool) -> list[str]: +def project_digest(key: str, c: dict) -> list[str]: + """One project as the check-in reads it back: what the human said they + were doing, what the ledger says is on the cluster, what they last wrote + down, and the three lines they are most likely to type next. + + No pull column and no `jobs` block: this digest is the ledger, and the + ledger is readable on any surface. What the cluster says is `pull`'s to + print, on the laptop that can ask it. + """ d = ledger_of(c, key) - row = c["projects"].get(key, {}) L = [f"## {key} — {d['summary'] if d else '(no ledger)'}", ""] - if skipped: - L.append("pull: skipped (--skip-pull)") - elif pull is None: - L.append("pull: not run") - else: - rc, note = pull - L.append("pull: ok" if rc == 0 else f"pull: {note or f'exited {rc}'}") - if jobs is None: - has = "jobs" in (row.get("sync_verbs") or []) - L.append("jobs: " + ("no runs listed — not asked" if has else "no jobs verb")) - else: - L += ["jobs:", jobs] - L.append("") if d is None: L += ["(no projects/.md — `python3 scripts/cortex.py new " f"{key} --summary ...` opens one)", ""] @@ -952,50 +992,137 @@ def project_digest(key: str, c: dict, pull: tuple | None, jobs: str | None, return L -def cmd_checkin(root: Path, mod, a) -> int: +# -------------------------------------------------------------- the pull --- +def cmd_pull(root: Path, mod, a) -> int: + """The laptop leg: each project's own ` pull`, then its `jobs` + output verbatim. Nothing else — no stamp, no render, no push. + + It is a separate verb because it has a separate precondition: every path + it runs under is a `local_path` out of `projects.yaml`, which exists on + exactly one machine. Asked anywhere else it says so once, by project, + rather than failing a pull per project. + """ projects, _ = mod.load_projects(root) ledgers, _ = mod.load_ledgers(root) keys, notes = checkin_keys(projects, ledgers, a.project) runs_by_key = {led.key: len(led.runs) for led in ledgers} + present, missing = split_by_root(projects, keys) - if not a.apply: - print("== Cortex check-in — dry run (nothing is reached) ==") + def jobs_line(key: str) -> str: + row = projects[key] + return f"cd {row.get('local_path')} && {row.get('sync_cli')} jobs" + + def asks_jobs(key: str) -> bool: + return bool(runs_by_key.get(key)) and \ + "jobs" in (projects[key].get("sync_verbs") or []) + + if a.dry_run: + print("== Cortex pull — dry run (nothing is reached) ==") for key in keys: row = projects[key] - print(f"\n{key} — {row.get('status')}") + here = "" if key in present else " (not on this machine)" + print(f"\n{key} — {row.get('status')}{here}") print(f" $ {pull_shell(row)}") - if runs_by_key.get(key) and "jobs" in (row.get("sync_verbs") or []): - print(f" $ cd {row.get('local_path')} && {row.get('sync_cli')} jobs") + if asks_jobs(key): + print(f" $ {jobs_line(key)}") for n in notes: print(f"\nnote: {n}") - print(f"\n{len(keys)} project(s) would be pulled. Run with --apply to " - "check in.") + print(f"\n{len(present)} of {len(keys)} project(s) would be pulled. " + "Run without --dry-run to pull.") return RC_OK - # The push decision is read before anything is written. - push_ok, push_why = push_preflight(root) - push = push_ok if a.push is None else a.push - push_note = "" - if push and not push_ok: - push, push_note = False, f"push: REFUSED — {push_why} ({PUSH_RULE})" - elif not push: - push_note = f"push: off — {push_why if a.push is None else '--no-push'}" + for n in notes: + print(f"note: {n}") + if not keys: + print("no project to pull — no `status: active` row and no ledger " + "lists a run.") + return RC_OK + if not present: + print("cortex pull: no project's `local_path` is on this machine:", + file=sys.stderr) + for key in missing: + print(f" - {key}: {_root_of(projects, key)} is not here", + file=sys.stderr) + print(f" {NOT_THE_LAPTOP}", file=sys.stderr) + return RC_USAGE - pulls: dict[str, tuple] = {} - if not a.skip_pull: - pulls = run_pull_streamed(projects, keys) + pulls = run_pull_streamed(projects, present) jobs_out: dict[str, str] = {} - for key in keys: + for key in present: if not runs_by_key.get(key): continue out = run_jobs(projects[key]) if out is None: continue jobs_out[key] = out - print(f"\n$ cd {projects[key].get('local_path')} && " - f"{projects[key].get('sync_cli')} jobs", flush=True) + print(f"\n$ {jobs_line(key)}", flush=True) print(out, flush=True) + failed = [k for k, (rc, _n) in pulls.items() if rc not in (0, None)] + print("\n# The cluster by project — pull\n") + for key in present: + rc, note = pulls.get(key, (None, "not run")) + print(f"{key}: " + ("pull ok" if rc == 0 else + (note or f"pull exited {rc}"))) + if key in jobs_out: + print(jobs_out[key]) + elif asks_jobs(key): + print(" (jobs printed nothing)") + else: + has = "jobs" in (projects[key].get("sync_verbs") or []) + print(" jobs: " + ("no runs listed — not asked" if has + else "no jobs verb")) + for key in missing: + print(f"{key}: skipped — {_root_of(projects, key)} is not on this " + "machine") + if missing: + print(f" {NOT_THE_LAPTOP}") + print("\nRecord what the jobs output says with `python3 scripts/cortex.py " + "running|done ` in the Cortex checkout; a result or a " + "lesson is written only in the human's words. Then " + "`pyauto-brain cortex checkin --apply` stamps and re-renders the " + "board.") + return RC_DRIFT if failed else RC_OK + + +# -------------------------------------------------------------- the door --- +def cmd_checkin(root: Path, mod, a) -> int: + """The door, on any surface: stamp, render, push, read the ledger back. + + It reaches no cluster and shells out to no sync CLI — every path such a + CLI runs under exists on the laptop alone, so a check-in that pulled was + a check-in that only worked in one place. `pull` is that leg now. + """ + projects, _ = mod.load_projects(root) + ledgers, _ = mod.load_ledgers(root) + keys, notes = checkin_keys(projects, ledgers, a.project) + if a.skip_pull: + notes.append("--skip-pull: accepted and ignored — `checkin` no longer " + "pulls; the pull is `pyauto-brain cortex pull`, on the " + "laptop") + + if not a.apply: + print("== Cortex check-in — dry run (nothing is written) ==") + for key in keys: + print(f"\n{key} — {projects[key].get('status')}") + for n in notes: + print(f"\nnote: {n}") + print(f"\nwould stamp {CHECKIN_FILE}, re-render dashboard.md + " + "dashboard.html, and read back " + f"{len(keys)} project(s). Run with --apply to check in.") + print("The pull is its own verb, on the laptop: " + "`pyauto-brain cortex pull`.") + return RC_OK + + # The push decision is read before anything is written. + push_ok, push_why = push_preflight(root) + push = push_ok if a.push is None else a.push + push_note = "" + if push and not push_ok: + push, push_note = False, f"push: REFUSED — {push_why} ({PUSH_RULE})" + elif not push: + push_note = f"push: off — {push_why if a.push is None else '--no-push'}" + stamp = _utc_now() write_checkin(root, stamp) c = census(root) @@ -1006,7 +1133,6 @@ def cmd_checkin(root: Path, mod, a) -> int: if push: _ok, push_lines = push_ledger(root, stamp[:10], dirty_paths(root)) - failed = [k for k, (rc, _n) in pulls.items() if rc not in (0, None)] print(f"\n# The Cortex by project — check-in {stamp}\n") print(f"{len(keys)} project(s) · {c['counts']['running']} running · " f"{c['counts']['open']} open · pages re-rendered") @@ -1017,12 +1143,13 @@ def cmd_checkin(root: Path, mod, a) -> int: "run `python3 scripts/cortex.py check`") print() for key in keys: - print("\n".join(project_digest(key, c, pulls.get(key), jobs_out.get(key), - a.skip_pull))) - print("Record what the jobs output says with `python3 scripts/cortex.py " - "running|done ` in the Cortex checkout; a result or a " - "lesson is written only in the human's words.") - return RC_DRIFT if failed or c["problems"] else RC_OK + print("\n".join(project_digest(key, c))) + print("The runs above are what the ledger says, not what the cluster " + "says: `pyauto-brain cortex pull` on the laptop asks the cluster, " + "and `python3 scripts/cortex.py running|done ` records " + "what it answered. A result or a lesson is written only in the " + "human's words.") + return RC_DRIFT if c["problems"] else RC_OK # ------------------------------------------------------------ the issue --- @@ -1114,30 +1241,36 @@ def common(p): help="exit 1 if the committed pages are stale") d.add_argument("--apply", action="store_true", help="write both pages") + u = common(sub.add_parser( + "pull", help="the laptop leg: pull every active project through its " + "own sync CLI and print its `jobs` output verbatim")) + u.add_argument("--project", action="append", default=[], metavar="KEY", + help="pull only these projects (repeatable)") + u.add_argument("--dry-run", dest="dry_run", action="store_true", + help="name every pull and reach nothing") + n = common(sub.add_parser( - "checkin", help="the check-in door: pull every active project through " - "its own sync CLI, show where each run stands, " - "re-render the board and read it back by project")) + "checkin", help="the check-in door, on any surface: stamp, re-render " + "the board, push the ledger and read it back by " + "project (it reaches no cluster — that is `pull`)")) n.add_argument("--dry-run", dest="dry_run", action="store_true", - help="the default — say what would be pulled and touch " + help="the default — say what would be written and write " "nothing") n.add_argument("--apply", action="store_true", - help="do it: pull, jobs, stamp, render (and push, per the " - "push rule)") + help="do it: stamp, render (and push, per the push rule)") n.add_argument("--push", dest="push", action="store_const", const=True, default=None, help="push the ledger diff on `claude/checkin-` " - "(allowed only when `gh auth status` succeeds and the " - "Cortex is clean on main; also the default when " - "neither flag is given)") + "(allowed when the Cortex checkout is clean on `main` " + "with an `origin`; also the default when neither flag " + "is given)") n.add_argument("--no-push", dest="push", action="store_const", const=False, - help="never push — the default in any session without a " - "logged-in `gh`") + help="never push — leave the check-in in the checkout") n.add_argument("--project", action="append", default=[], metavar="KEY", - help="sweep only these projects (repeatable)") + help="read back only these projects (repeatable)") n.add_argument("--skip-pull", dest="skip_pull", action="store_true", - help="do not pull — stamp, render and read back what is " - "already on the laptop") + help="accepted and ignored — `checkin` no longer pulls " + "(kept so an old paste still runs)") i = common(sub.add_parser( "issue", help="the ledger block that sits at the top of each " @@ -1163,6 +1296,8 @@ def main(argv=None) -> int: return RC_USAGE try: + if verb == "pull": + return cmd_pull(root, mod, a) if verb == "checkin": return cmd_checkin(root, mod, a) if verb == "issue": diff --git a/agents/conductors/cortex/cortex.sh b/agents/conductors/cortex/cortex.sh index 8d5b2a9a..f96dcc13 100755 --- a/agents/conductors/cortex/cortex.sh +++ b/agents/conductors/cortex/cortex.sh @@ -5,19 +5,23 @@ # # Reasons over PyAutoCortex, the organ that holds the science body map and one # ledger per project (Now, Runs, Log): renders the Cortex board (dashboard.md -# + dashboard.html, published to Pages), runs the check-in (each project's own -# sync CLI, its `jobs` output verbatim) and syncs the ledger block onto each -# project's issue. It records cluster facts and the human's words, never a -# verdict of its own — a run is submitted only on the human's ask, and a -# result or lesson is logged only in their words. +# + dashboard.html, published to Pages), runs the check-in (stamp, render, +# push, read the ledger back by project — on any surface), pulls the cluster +# through each project's own sync CLI (the laptop only, where the science +# roots are) and syncs the ledger block onto each project's issue. It records +# cluster facts and the human's words, never a verdict of its own — a run is +# submitted only on the human's ask, and a result or lesson is logged only in +# their words. # # Usage: # cortex.sh # census (default) # cortex.sh census --json # machine-readable # cortex.sh dashboard --check # exit 1 if the pages are stale # cortex.sh dashboard --apply # write dashboard.md + dashboard.html -# cortex.sh checkin --dry-run # what it would pull; reaches nothing -# cortex.sh checkin --apply # the check-in: pull, jobs, stamp, render, push +# cortex.sh pull # the laptop: each project's pull, then jobs verbatim +# cortex.sh pull --dry-run # what it would pull; reaches nothing +# cortex.sh checkin --dry-run # what it would write; writes nothing +# cortex.sh checkin --apply # the check-in: stamp, render, push, read back # cortex.sh issue [--apply] # the ledger block for each project's issue # cortex.sh --cortex # point at another PyAutoCortex checkout diff --git a/agents/conductors/intake/AGENTS.md b/agents/conductors/intake/AGENTS.md index 983b2f47..ccec91bf 100644 --- a/agents/conductors/intake/AGENTS.md +++ b/agents/conductors/intake/AGENTS.md @@ -90,6 +90,16 @@ Writes the light header PyAutoMind blesses (`README.md` "Prompt file format"), extended with `Difficulty:/Autonomy:/Priority:`. No YAML frontmatter, no required schema — light structure over free-form prose. +`Memory:` rides under `Priority:`: the top 3 PyAutoMemory pages for this +prompt's own text, `;`-separated and repo-relative, written at filing time by +the memory faculty's own ranking function. The doctrine says every plan +consults Memory and the record says it happened about six times in 1,547 +tasks, so intake consults it mechanically and the citations sit in front of +the session that picks the prompt up. PyAutoMemory only — Mind history and the +assistant are operational recall, not what the science says — and no hits (or +no PyAutoMemory checkout) writes no line at all, because an empty `Memory:` +would claim nothing is known. + `Themes:` is written at formalisation, directly under `Repos:` and in the same list shape (`intake classify --themes mge,jax-gradient`, primary keyword first). `Target:` says where the code lives; `Themes:` says what the work is diff --git a/agents/conductors/intake/INTAKE_TAXONOMY.md b/agents/conductors/intake/INTAKE_TAXONOMY.md index 6b372289..eb96105a 100644 --- a/agents/conductors/intake/INTAKE_TAXONOMY.md +++ b/agents/conductors/intake/INTAKE_TAXONOMY.md @@ -90,6 +90,7 @@ Repos: Difficulty: Autonomy: Priority: +Memory: wiki/lensing/concepts/foo.md; wiki/methods/sources/bar.md Status: formalised @@ -101,6 +102,16 @@ No YAML, no required fields — this is the light header PyAutoMind blesses in `README.md` "Prompt file format", extended with the three intake keys (`Difficulty:/Autonomy:/Priority:`). `Type:` always matches the work-type folder. +**`Memory:`** — the top 3 **PyAutoMemory** pages for this prompt's own text +(title + the first ~200 words of the body), repo-relative and `;`-separated, +written at filing time by the memory faculty's own ranking function. The +doctrine says every plan consults Memory; the record says it happened about six +times in 1,547 tasks, so intake consults it mechanically and the citations are +in front of the session that picks the prompt up. PyAutoMemory only — Mind +history and the assistant are operational recall, not what the science says. No +hits, or no PyAutoMemory checkout, writes **no line at all**: an empty +`Memory:` would claim nothing is known. Optional on read, like every other key. + ## 6. Census + dashboard (reading the taxonomy back) The write path above has a read path: **census** walks every work-type folder diff --git a/agents/conductors/intake/_intake.py b/agents/conductors/intake/_intake.py index d10dbc43..ca42a7e8 100755 --- a/agents/conductors/intake/_intake.py +++ b/agents/conductors/intake/_intake.py @@ -47,6 +47,13 @@ _body_map_specs as _sizing_specs, ) +# The memory faculty, imported rather than shelled out to: intake files prompts +# in bulk (`intake ideas --apply` formalises the whole inbox in one go) and a +# subprocess per prompt would pay the interpreter start-up every time. It is the +# same ranking function the `/memory` verb prints — one recall implementation. +sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "faculties" / "memory")) +import _memory # noqa: E402 + # The shared board theme: the one place that answers "what does a one-tap board # look like". Presentation only — the stylesheet, the hero, the pills — so this # page and the Brain board are visibly the same family (board/_theme.py). @@ -531,6 +538,64 @@ def _next_action(proposed, confidence, work_type=None): # --- apply (the only writing path) ------------------------------------------- +# --- Memory citations --------------------------------------------------------- +# The doctrine says every plan consults Memory. The record says it was consulted +# about six times in 1,547 completed tasks, because consulting it is a step a +# human has to remember. So intake does it mechanically: every prompt it files +# carries the top PyAutoMemory pages for its own text, as a `Memory:` header +# line, and the session that picks the prompt up has the citations in front of +# it before it plans anything. +# +# PyAutoMemory ONLY — not Mind history, not the assistant. Those two are +# operational recall (what the organism did); this line answers "what does the +# science say", which is the half a plan cannot reconstruct from the repo. A +# prompt with no hits, or filed on a box with no PyAutoMemory, gets no line at +# all: an empty `Memory:` would read as "nothing is known", which is a claim +# this has no standing to make. +MEMORY_CITATIONS = 3 +MEMORY_QUERY_WORDS = 200 + + +def _memory_home(mind: Path) -> Path | None: + """The PyAutoMemory checkout beside this Mind, or None when it is absent.""" + override = os.environ.get("PYAUTO_MEMORY", "") + home = Path(override) if override else mind.parent / "PyAutoMemory" + return home if home.is_dir() else None + + +def memory_citations(mind: Path, title: str, body_text: str, + limit: int = MEMORY_CITATIONS) -> list: + """The top PyAutoMemory pages for this prompt, as repo-relative paths. + + The query is the title plus the head of the body: a prompt's opening states + the problem, while its tail is usually acceptance criteria and file paths + that match on vocabulary rather than subject. + """ + home = _memory_home(mind) + if home is None: + return [] + query = " ".join(f"{title} {body_text}".split()[:MEMORY_QUERY_WORDS]) + try: + d = _memory.digest(query, home, None, None, limit) + except (OSError, ValueError): + return [] + return [page["page"] for page in d["pages"]][:limit] + + +def _with_memory(header: str, pages: list) -> str: + """`Memory: a.md; b.md` under the optional keys, or the header unchanged.""" + if not pages: + return header + line = "Memory: " + "; ".join(pages) + lines = header.split("\n") + for i, text in enumerate(lines): + if text.startswith("Priority:"): + lines.insert(i + 1, line) + return "\n".join(lines) + lines.append(line) + return "\n".join(lines) + + def write_prompt(mind: Path, decision: dict, body_text: str, source_note: str): """Write the formal prompt file. Returns the path written (relative to mind).""" rel = Path(decision["proposed_path"]) @@ -543,6 +608,13 @@ def write_prompt(mind: Path, decision: dict, body_text: str, source_note: str): date = _dt.date.today().isoformat() note = (f"\n\n\n") + # Consulted at FILING time, not at analysis time: `analyse` is pure and + # touches no filesystem, and a citation is only worth computing for a + # prompt that is actually going to exist. The decision carries the header + # that was written, so `--json` reports the file's real contents. + cites = memory_citations(mind, decision.get("title", ""), body_text) + decision["memory"] = cites + decision["header"] = _with_memory(decision["header"], cites) dest.write_text(decision["header"] + "\n\n" + body_text.strip() + note, encoding="utf-8") return str(rel) @@ -600,7 +672,8 @@ def parse_header(text: str) -> dict: for line in text.splitlines()[:30]: m = re.match(r"(Type|Target|Difficulty|Autonomy|Priority|Status|" r"Issued|Filed|Epic|Phase|Bundle|Blocked-by|" - r"Consequence|Witness|Review-minutes|Unattended|Lane):\s*(\S.*)", + r"Consequence|Witness|Review-minutes|Unattended|Lane|" + r"Memory):\s*(\S.*)", line.strip()) if m: fields.setdefault(m.group(1).lower(), m.group(2).strip()) diff --git a/agents/faculties/memory/_memory.py b/agents/faculties/memory/_memory.py index 6752a8fb..8488a656 100755 --- a/agents/faculties/memory/_memory.py +++ b/agents/faculties/memory/_memory.py @@ -52,6 +52,14 @@ def surfaces(memory: Path | None, assistant: Path | None, mind: Path | None): wikis += sorted(memory.glob("*_wiki")) for wiki in wikis: for f in wiki.rglob("*.md"): + # `wiki//seed/` holds UNVERIFIED import stubs — pages + # pulled in mechanically and not yet read by a human. They are + # kept in the repo on purpose, but a faculty that cites them + # would be handing an agent unchecked material with the same + # authority as a verified page, so they are not a recall + # surface until they leave seed/. + if "seed" in f.relative_to(wiki).parts: + continue yield f"PyAutoMemory/{wiki.name}", memory, f if assistant and assistant.is_dir(): for sub in ("skills", "wiki"): diff --git a/agents/faculties/vitals/AGENTS.md b/agents/faculties/vitals/AGENTS.md index 978ad174..18cfb748 100644 --- a/agents/faculties/vitals/AGENTS.md +++ b/agents/faculties/vitals/AGENTS.md @@ -50,6 +50,33 @@ bin/pyauto-brain vitals dashboard --json # forward: the board as one machine c bin/pyauto-brain vitals readiness --json # forward: pyauto-heart readiness --json (no tick) bin/pyauto-brain vitals status # forward to: pyauto-heart status bin/pyauto-brain vitals watch 300 # forward to: pyauto-heart watch 300 +bin/pyauto-brain vitals --scope PyAutoFit # scoped verdict from the published board +``` + +## Without the Heart CLI + +A web/mobile session never holds the PyAutoHeart checkout, so `resolve_heart` +fails — and the faculty used to *exit*, leaving the ship gate with no verdict at +all. It now falls back to the Heart's **published board** (the same GitHub Pages +`badge.json` + `board.json` the Brain board reads), via +[`_vitals.py`](./_vitals.py). That is not a live tick — it is as fresh as the +Heart's last publish, and every line of the output says so. Unreachable Pages +print `verdict: UNKNOWN (Pages unreachable: …)` and exit 3; a gate reads that as +unknown → YELLOW, never as GREEN. + +## `--scope [,...]` + +The organism-wide verdict is one number over every repo, so a PyAutoFit branch +was acknowledging a RED caused by an `autogalaxy_workspace` smoke failure it +could not have caused. `--scope` filters the published blockers to those naming +the given repos and prints a **scoped** verdict beside the organism-wide one — +GREEN when nothing in scope blocks, otherwise the worst in-scope severity. It +always reads the published board (that is where the per-repo blockers live), CLI +present or not, and says so. + +```bash +bin/pyauto-brain vitals --scope PyAutoFit # scoped verdict + blockers +bin/pyauto-brain vitals --scope PyAutoFit,PyAutoLens --json ``` The entrypoint (`vitals.sh`) refreshes Heart's state and renders the **unified diff --git a/agents/faculties/vitals/HEART_CAPABILITIES.md b/agents/faculties/vitals/HEART_CAPABILITIES.md index 040b1c81..40a3d5cf 100644 --- a/agents/faculties/vitals/HEART_CAPABILITIES.md +++ b/agents/faculties/vitals/HEART_CAPABILITIES.md @@ -74,6 +74,12 @@ reimplement inside Brain. - **The vitals faculty renders the card from `pyauto-heart dashboard --json`/`--md`** — the same board, not raw verdict JSON. It is exposed as the `dashboard` capability + `published_board` URL in Heart's `health_agent/capabilities.yaml`. +- **The published Pages board is also the faculty's FALLBACK read.** With no + `pyauto-heart` on the box (every web/mobile session), the faculty reads that + surface's `badge.json` + `board.json` directly — the verdict, the structured + blockers, the publish timestamp — and labels the answer published, not live. + It is also the only surface carrying per-repo blockers, so `--scope` reads it + even when the CLI is present. - **Observer-only.** The dashboard SHOWS health; the `readiness` verdict stays the gate. Everything the dashboard writes stays within PyAutoHeart's own repo (gh-pages / README / `[heart-health]` issue), the job step summary, or diff --git a/agents/faculties/vitals/_vitals.py b/agents/faculties/vitals/_vitals.py new file mode 100755 index 00000000..d70dc316 --- /dev/null +++ b/agents/faculties/vitals/_vitals.py @@ -0,0 +1,215 @@ +#!/usr/bin/env python3 +"""_vitals.py — the vitals faculty when the Heart CLI is not here. + +WHY. `vitals.sh` drives `pyauto-heart`, and a web/mobile session never has the +PyAutoHeart checkout — so `resolve_heart` failed and the faculty exited, which +meant the ship gate ran with NO verdict at all rather than a qualified one. The +Heart already publishes its board to GitHub Pages and the Brain board already +reads it; this reads the same two files and answers from them. + +WHAT IT IS NOT. A published board is not a live tick: it is as fresh as the +Heart's last publish, and every line of output says so. When the CLI is +present, `vitals.sh` still drives it for the organism-wide read. + +SCOPE. `--scope [,...]` answers the question a branch actually has: +"is anything blocking MY repo?". The organism-wide verdict is one number over +every repo, so a library branch was acknowledging a RED raised by a workspace +smoke failure three repos away — one it could not have caused and cannot fix. +The scoped verdict keeps both: GREEN in scope, RED organism-wide, both printed. + +The fetch and the blocker extraction are NOT reimplemented here — they are +`board/_board.py`'s (`fetch_badge`, `fetch_heart_board`, +`extract_heart_blockers`), imported, so the Brain reads the Heart's surface +through exactly one parser. + +Exit: 0 a verdict was read · 2 usage · 3 the published board is unreachable. +""" + +from __future__ import annotations + +import argparse +import json +import os +import sys +from pathlib import Path + +BRAIN_HOME = Path(__file__).resolve().parents[3] +sys.path.insert(0, str(BRAIN_HOME / "board")) + +import _board # noqa: E402 + +# Heart's tiers, worst first. The scoped verdict is the worst severity among +# the in-scope blockers, so it needs their order — the same precedence Heart +# applies in `readiness.py` (red dominates yellow dominates stale). +SEVERITY_RANK = {"red": 3, "yellow": 2, "amber": 2, "stale": 1} +VERDICTS = ("RED", "YELLOW", "STALE", "GREEN") + + +def pages_source(): + """(pages_base, heart_repo) — resolved exactly as the Brain board does. + + `BOARD_PAGES_BASE` wins, so a test (or a mirror) can point this elsewhere + without a checkout; otherwise the org comes from the Mind's body map. + """ + cfg = _board.load_policy() + heart_repo = cfg.get("heart_board", "PyAutoHeart") + base = os.environ.get("BOARD_PAGES_BASE") + if not base: + org = _board.derive_org(_board.repo_homes()) + if org is None: + return None, heart_repo + base = f"https://{org.lower()}.github.io" + return base, heart_repo + + +def read_published(pages_base, heart_repo): + """(badge, board, degraded) from the Heart's published Pages surface.""" + degraded: list[str] = [] + badge = _board.fetch_badge(pages_base, heart_repo) + board = _board.fetch_heart_board(pages_base, heart_repo, degraded) + return badge, board, degraded + + +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.""" + 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" + + +def board_timestamp(board): + """When the published board was generated. Heart's key has changed name + across schema versions, so accept any of them rather than pinning one.""" + for key in ("generated", "generated_at", "ts", "timestamp", "as_of", "updated"): + value = (board or {}).get(key) + if value: + return str(value) + return "unknown" + + +def parse_scope(raw): + """`--scope a,b` / repeated `--scope` -> a lowercased list of repo names.""" + names = [] + for chunk in raw or []: + for name in str(chunk).split(","): + name = name.strip() + if name and name.lower() not in names: + names.append(name.lower()) + return names + + +def in_scope(blocker, scope): + """Does this blocker name one of the scoped repos? + + A blocker carries a `repo` field, but not always (an organism-wide gap has + none) — and its `text` is what a reader recognises. So match either: the + repo field exactly, or the repo name anywhere in the text. Matching the + text is deliberately generous; missing a blocker that IS yours is the + expensive direction. + """ + repo = str(blocker.get("repo") or "").lower() + text = str(blocker.get("text") or "").lower() + return any(name == repo or name in text for name in scope) + + +def worst(blockers): + """The worst severity among these blockers, as a verdict word.""" + rank = max((SEVERITY_RANK.get(str(b.get("severity") or "").lower(), 0) + for b in blockers), default=0) + if rank == 0: + # Blockers with no severity Heart recognises are still blockers; they + # must not read as GREEN. + return "YELLOW" if blockers else "GREEN" + return {3: "RED", 2: "YELLOW", 1: "STALE"}[rank] + + +def render_blocker(b): + sev = f"[{b['severity']}] " if b.get("severity") else "" + line = f" {sev}{b.get('text', '')}" + if b.get("run_url"): + line += f" — {b['run_url']}" + return line + + +def main(argv=None): + p = argparse.ArgumentParser( + prog="_vitals.py", + description="Read the Heart's PUBLISHED board (no pyauto-heart needed).") + p.add_argument("--scope", action="append", metavar="REPO[,REPO...]", + help="filter blockers to these repos and print a scoped verdict") + p.add_argument("--json", action="store_true", help="machine output") + args = p.parse_args(argv) + scope = parse_scope(args.scope) + + pages_base, heart_repo = pages_source() + if pages_base is None: + print("verdict: UNKNOWN (Pages unreachable: cannot derive the GitHub " + "org — no body map and no git remote)") + return 3 + + badge, board, degraded = read_published(pages_base, heart_repo) + if badge is None and board is None: + why = degraded[0] if degraded else "unreachable" + print(f"verdict: UNKNOWN (Pages unreachable: {why})") + return 3 + + organism = verdict_of(badge, board) + blockers = _board.extract_heart_blockers(board) + # Scope filters the board's RAW blockers before extraction, not the + # extracted five: `extract_heart_blockers` caps the list for a morning + # glance, and a cap that silently drops the one blocker that IS yours + # would turn a scoped read into a lie. Same extractor, narrower input. + if scope: + raw = [b for b in ((board or {}).get("blockers") or []) + if in_scope(b, scope)] + scoped = _board.extract_heart_blockers({"blockers": raw}) + scoped_verdict = worst(scoped) + else: + scoped, scoped_verdict = blockers, organism + source = f"{pages_base}/{heart_repo}/" + note = ("this is the PUBLISHED Heart board, not a live tick — it is as " + "fresh as the Heart's last publish") + + if args.json: + print(json.dumps({ + "verdict": organism, + "scope": scope, + "scoped_verdict": scoped_verdict, + "blockers": blockers, + "scoped_blockers": scoped, + "generated": board_timestamp(board), + "source": source, + "published": True, + "note": note, + "degraded": degraded, + }, indent=2)) + return 0 + + print(f"== vitals faculty: the published Heart board ({source}) ==") + print(f"note: {note}") + print(f"verdict: {organism}") + print(f"generated: {board_timestamp(board)}") + if scope: + print(f"scope: {', '.join(scope)}") + print(f"scoped verdict: {scoped_verdict} (organism-wide: {organism})") + rows = scoped if scope else blockers + label = "in-scope blockers" if scope else "blockers" + if rows: + print(f"{label} ({len(rows)}):") + for b in rows: + print(render_blocker(b)) + else: + print(f"{label}: none") + for row in degraded: + print(f"degraded: {row}") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/agents/faculties/vitals/vitals.sh b/agents/faculties/vitals/vitals.sh index 730f3b04..1c9462d6 100755 --- a/agents/faculties/vitals/vitals.sh +++ b/agents/faculties/vitals/vitals.sh @@ -16,8 +16,21 @@ # vitals.sh # one tick, then render the unified dashboard card # vitals.sh status # forward: pyauto-heart status # vitals.sh watch [secs] # forward: pyauto-heart watch (continuous) +# vitals.sh --scope [,...] # verdict scoped to those repos (+ --json) # vitals.sh ... # forward verbatim to pyauto-heart # +# WITHOUT THE HEART CLI. A web/mobile session never holds the PyAutoHeart +# checkout, so `resolve_heart` failed and this faculty exited — the ship gate +# then ran with no verdict at all, which is worse than a qualified one. When the +# CLI cannot be resolved we read the Heart's PUBLISHED board instead +# (`_vitals.py`, the same Pages JSON the Brain board reads). It is not a live +# tick and says so on every line. +# +# --scope ALWAYS reads the published board, CLI or no CLI: the per-repo +# blockers live in the Heart's `board.json`, and that is the surface that can +# say a RED belongs to some other repo's workspace smoke and not to the library +# branch asking. The output names its source so the two are never confused. +# # The no-arg card is the SAME unified board every other surface shows (one # renderer in heart/dashboard.py) — verdict, score, top blockers, and the # release-validation state — not raw verdict JSON. On a phone the reasoning @@ -32,7 +45,46 @@ set -uo pipefail HERE="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)" source "$HERE/../../_common.sh" -heart="$(resolve_heart)" || exit $? +PAGES_READER="$HERE/_vitals.py" + +# This faculty's OWN flags (--scope/--json), recognised only when they are the +# whole argument list. Anything else — `dashboard --json`, `readiness --json` — +# is a pyauto-heart subcommand line and is forwarded verbatim, unread: stripping +# a `--json` that belonged to Heart would silently turn a machine card into a +# human one. +scope=""; want_json=0; ours=1; rest=("$@") +while [[ $# -gt 0 ]]; do + case "$1" in + --scope) scope="${2:-}"; shift; shift || true ;; + --scope=*) scope="${1#--scope=}"; shift ;; + --json) want_json=1; shift ;; + *) ours=0; break ;; + esac +done +if [[ "$ours" -eq 0 ]]; then scope=""; want_json=0; else rest=(); fi + +pages_read() { + local args=() + [[ -n "$scope" ]] && args+=(--scope "$scope") + [[ "$want_json" -eq 1 ]] && args+=(--json) + python3 "$PAGES_READER" "${args[@]}" +} + +# A scoped read is a published-board question by construction — answer it and +# stop, so a scoped verdict is never half live and half published. +if [[ -n "$scope" ]]; then + pages_read; exit $? +fi + +if ! heart="$(resolve_heart)"; then + echo "== vitals faculty: no pyauto-heart here — reading the published Heart board ==" >&2 + pages_read; exit $? +fi + +# A bare `--json` with the CLI here is a live machine card, not a published one. +if [[ "$want_json" -eq 1 ]]; then exec "$heart" dashboard --json; fi + +set -- "${rest[@]+"${rest[@]}"}" if [[ $# -eq 0 ]]; then echo "== vitals faculty: refreshing PyAutoHeart state ==" diff --git a/bin/branch_sweep.sh b/bin/branch_sweep.sh index ede3599a..20106a97 100755 --- a/bin/branch_sweep.sh +++ b/bin/branch_sweep.sh @@ -288,6 +288,35 @@ fi # the branch, so the first few failures already answer the question for # all of them. Grinding through 99 doomed pushes just buries the reason # and burns the API budget. +# WHICH line of a failed push is the reason. `grep -m1 error|fatal` looked +# enough until a run hit git's own chatter first: with `push.negotiate` set, +# git 2.43 emits `fatal: --negotiate-only needs one or more +# --negotiation-tip=*` followed by `warning: push negotiation failed; +# proceeding anyway` BEFORE the push it then goes on to make and have refused. +# The first `fatal:` in the output was therefore a harmless fallback notice, +# and the actual `remote: error: denying ref deletion` three lines below it was +# never printed. Versions also differ in what they say and whether the server's +# words arrive `remote:`-prefixed, so rank rather than take-the-first: the +# server's own refusal, then git's per-ref rejection line, then any remaining +# error, then whatever there is. Noise lines are dropped outright — they +# describe a retry, not a failure. +push_failure_reason() { + local raw="$1" line + local clean + clean=$(printf '%s\n' "$raw" \ + | sed 's/\r$//; s/^remote:[[:space:]]*//; s/[[:space:]]*$//' \ + | grep -v '^$' \ + | grep -viE 'negotiat|^warning:|^to |^everything up-to-date') + for pat in \ + '(denying|denied|permission|forbidden|protected|not allowed|pre-receive)' \ + '^!?[[:space:]]*\[(remote )?rejected\]|\[rejected\]' \ + '^(error|fatal):' + do + line=$(grep -iEm1 "$pat" <<<"$clean") && [ -n "$line" ] && { printf '%s\n' "$line"; return 0; } + done + head -1 <<<"$clean" +} + deleted=0 failed=0 n=0 streak=0 for entry in "${safe[@]}"; do b="${entry%% *}" @@ -298,7 +327,7 @@ for entry in "${safe[@]}"; do if err=$(g push origin --delete "$b" 2>&1); then echo " deleted $b"; deleted=$((deleted + 1)); streak=0 else - reason=$(grep -iEm1 'error|fatal|denied|forbidden|protected' <<<"$err" | sed 's/^remote: *//;s/[[:space:]]*$//') + reason=$(push_failure_reason "$err") echo " FAILED $b — ${reason:-no error text returned}" failed=$((failed + 1)); streak=$((streak + 1)) if [[ "$streak" -ge 3 ]]; then diff --git a/bin/install.sh b/bin/install.sh index aa006f30..74ca5d65 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -35,6 +35,7 @@ # bash PyAutoBrain/bin/install.sh --write-project-discovery # (re)generate committed # # .claude/ + .codex/ discovery per repo # bash PyAutoBrain/bin/install.sh --check-project-discovery # drift-check that discovery (exit 1) +# # trailing repo names narrow the check # # The command-surface modes are the agent-agnostic half of command discovery: # per-tool symlinks (above) are absent in cloud/web sessions, which load only @@ -243,9 +244,13 @@ write_project_discovery() { done } +# Optional trailing repo names narrow the check to those repos (the pytest leg +# checks PyAutoBrain alone, so a local run is not reddened by a sibling's drift). check_project_discovery() { local repo repo_dir want got drift=0 - for repo in "${DISCOVERY_REPOS[@]}"; do + local repos=("${DISCOVERY_REPOS[@]}") + [ "$#" -gt 0 ] && repos=("$@") + for repo in "${repos[@]}"; do repo_dir="$PYAUTO_ROOT/$repo" [ -d "$repo_dir/skills" ] || continue want="$(_discovery_manifest "$repo_dir")" @@ -265,7 +270,7 @@ case "${1:-}" in --write-agents-surface) write_agents_surface; exit 0 ;; --check-agents-surface) check_agents_surface; exit $? ;; --write-project-discovery) write_project_discovery; exit 0 ;; - --check-project-discovery) check_project_discovery; exit $? ;; + --check-project-discovery) shift; check_project_discovery "$@"; exit $? ;; --help|-h) sed -n '2,24p' "$0"; exit 0 ;; esac diff --git a/bin/pyauto-brain b/bin/pyauto-brain index a2122bf2..528f635d 100755 --- a/bin/pyauto-brain +++ b/bin/pyauto-brain @@ -18,7 +18,7 @@ # pyauto-brain workspace [args] (conductor) the Voice: plan/survey workspace + HowTo example authorship — WorkspaceDecision (writes nothing) # pyauto-brain eyes [args] (conductor) the Eyes: survey/review a visualization workspace's figure surface — EyesSurvey/EyesReviewSurface (writes nothing) # pyauto-brain profiling [args] (conductor) campaign/ingest/triage plans over the profiling workspace -# pyauto-brain cortex [args] (conductor) the science check-in: checkin/census/dashboard/issue +# pyauto-brain cortex [args] (conductor) the science check-in: pull/checkin/census/dashboard/issue # pyauto-brain hygiene [args] (conductor) code-quality upkeep: perf/tidy/noise/deps/docs — HygieneDecision (modes staged) # pyauto-brain clone [args] (conductor) analyze a library+workspace against the reference assistant — CloneDecision (writes nothing) # (clone sync: re-apply the reference's generic-file diff to its born @@ -87,7 +87,7 @@ declare -A AGENT_DESC=( [refactor]="The renewal function: plan behaviour-preserving restructuring — RefactorDecision; default-safe under --auto" [workspace]="The voice — the organism's expressive function: plan/survey workspace + HowTo example authorship (workspace|howto registers) — WorkspaceDecision (never writes)" [eyes]="The perceptive function — the organism's sense of its own appearance: survey/review a visualization workspace's figure surface, critiques route to intake/start_dev — EyesSurvey/EyesReviewSurface (never renders, never edits)" - [cortex]="The learning function — where the organism keeps track of what is true: the per-project science ledger over PyAutoCortex ('cortex checkin') — pull every active project through its own sync CLI, show where each run stands, re-render the board; it records cluster facts and the human's words, never a verdict of its own" + [cortex]="The learning function — where the organism keeps track of what is true: the per-project science ledger over PyAutoCortex — 'cortex pull' on the laptop pulls every active project through its own sync CLI and shows where each run stands; 'cortex checkin' anywhere stamps, re-renders the board and pushes the ledger; it records cluster facts and the human's words, never a verdict of its own" [profiling]="The proprioceptive function — the organism's sense of its own effort: campaign/ingest/triage plans over the autolens_profiling workspace — ProfilingDecision" [hygiene]="The maintenance function — the organism's sense of its own upkeep: code-quality debt (dev-loop cost + tidiness), delegating fixes — HygieneDecision" [clone]="The Mitosis Agent: partition the reference assistant, analyze the domain, emit the CloneDecision; --apply --mode lightweight-seed delegates the seed birth to Build; 'clone sync' patches the reference's generic-file diff onto the born siblings (dry run by default; rejected hunks are a human decision)" diff --git a/board/AGENTS.md b/board/AGENTS.md index bce2d773..5532b22e 100644 --- a/board/AGENTS.md +++ b/board/AGENTS.md @@ -133,10 +133,12 @@ Env: `PYAUTO_ROOT` (workspace root holding `PyAutoMind/`), `BOARD_GH` A Claude Code remote session (web/mobile) cannot reach either of the board's data sources by default: -- **`gh` is not installed.** The overnight sweep, the version stamps, the - community scan and the pending-release search all run through it. Without it - they cannot ask — which is not the same as asking and getting nothing, and - the render now says so (`could not read`, never `no runs`). +- **`gh` is not installed**, and installing one does not help + ([`../skills/GITHUB_ACCESS.md`](../skills/GITHUB_ACCESS.md) has the measured + reason). The overnight sweep, the version stamps, the community scan and the + pending-release search all run through it. Without it they cannot ask — which + is not the same as asking and getting nothing, and the render now says so + (`could not read`, never `no runs`). - **The sibling Pages boards are refused by the egress policy.** The proxy answers `403` to `CONNECT` for `.github.io`, so `board.json` and `badge.json` — the Heart's readiness surface among them — are unreadable. @@ -201,9 +203,9 @@ Three rules the seam does not get to bend: The alternative to the seam is an org admin connecting the Claude GitHub App, after which `$GH_TOKEN` would work from a subprocess and `gh_json()` could -become a plain REST helper on every surface. Probed 2026-08-27: 200 on `/user` -and `/rate_limit`, **403 on every repo-scoped path**. Re-probe before assuming -this seam is still needed — it is meant to be deletable. +become a plain REST helper on every surface. It did not when it was measured +(`../skills/GITHUB_ACCESS.md`). Re-probe before assuming this seam is still +needed — it is meant to be deletable. To get a complete board in a remote session, the environment needs outbound access to the Pages host. That is cloud-environment configuration on claude.ai, diff --git a/docs/concepts/agents.md b/docs/concepts/agents.md index 6b68adea..72641116 100644 --- a/docs/concepts/agents.md +++ b/docs/concepts/agents.md @@ -12,17 +12,10 @@ question: **does it act, or only opine?** conductors consult. They return a judgment and stop — never dispatch, never mutate. -The live conductor set: **intake** (raw idea → formal Mind prompt), -**feature** (plan the next growth task), **bug** (classify and route a -repair), **refactor** (behaviour-preserving restructuring), **workspace** -(the Voice — plan workspace + HowTo example authorship), **profiling** -(the organism's sense of its own effort), **hygiene** (the organism's sense -of its own upkeep), **clone** (reproduce a mature assistant into a new -cell), **build**, **release**, and **health** (the clinician loop toward -GREEN). The faculties behind them: -**vitals** (the only component that talks to Heart), **review** (the -automatic-review leg of the ship gate), **memory** (cited digests over the -Memory organ), and **samplers** (domain expertise for the live instance). +The live roster is never listed twice: the verb table in the Brain's +[AGENTS.md](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/AGENTS.md) is +generated from the router (`bin/pyauto-brain`), so it cannot drift from the +agents that exist. Each agent's own `AGENTS.md` carries its full role. ## The consult graph is a DAG diff --git a/docs/concepts/organism.md b/docs/concepts/organism.md index 9f766241..b5846160 100644 --- a/docs/concepts/organism.md +++ b/docs/concepts/organism.md @@ -11,10 +11,11 @@ it and adds the framework/instance distinction an adopter needs. |-------|------|-----| | **Brain** | PyAutoBrain | Figures out *how* — reasoning, planning, routing; hosts the specialist agents. Owns no state, no health checks, no execution mechanics. | | **Mind** | PyAutoMind | Decides *what* — intent, goals, priorities, workflow state, the prompt registry, and the body map (`repos.yaml`). | -| **Cortex** | PyAutoCortex | *Learns what is true* — the science body map (`projects.yaml`) and the rulings of record for every science run; the science mirror of the Mind (runs and rulings ↔ prompts and PRs). The Mind decides, the Brain routes, the Cortex learns; a verdict recorded only outside the Cortex does not exist. | +| **Cortex** | PyAutoCortex | *Keeps track of what is true* — the science body map (`projects.yaml`) and one ledger per science project (`## Now`, the `## Runs` on the cluster, a `## Log` that only gets longer); the science mirror of the Mind (runs and a dated log ↔ prompts and PRs). Not a task tracker: it records cluster facts and the human's words, never a verdict of its own. | | **Memory** | PyAutoMemory | *Knows* — long-term domain knowledge: literature wikis, concepts, bibliographies. Pull-only; consulted, never load-bearing at runtime. | | **Heart** | PyAutoHeart | Decides whether the organism is *healthy*. `pyauto-heart readiness` is the authoritative GREEN/YELLOW/RED release gate. An observer: never writes into other repos, never triggers a build. | | **Hands** | PyAutoHands | *Does* — packaging, tagging, notebook generation, PyPI releases. A pure executor: never re-derives a gate decision. | +| **Nerves** | PyAutoNerves | *Connects* — the configuration/serialization layer (`autonerves`): layered config, the workspace↔library version handshake, `test_mode`, FITS/JSON I/O. The base layer every library imports. | | **Gut** | PyAutoGut | *Sheds* — the lifecycle of condemned self-material (stale branches, stashes, dead code/tests): holds each as a durable, recoverable git ref through a transit window, then **voids** it on a sweep. The storage mirror of Memory (retention ↔ release); the hygiene conductor drives it, as vitals reads Heart. | Everything else — the libraries being developed, their example workspaces, @@ -25,13 +26,14 @@ organism expects of each are the {doc}`category contract <../satellites>`. ## The call chain ``` -Brain → Heart (gate) → Hands (execute) +Brain → Heart (gate) → Build (execute) ``` -Always in that order. The Brain asks Heart for the readiness verdict, -reasons over it, and only on GREEN triggers the Hands. Heart never triggers -a build; the Hands never re-check readiness. Each boundary exists so that no -organ has to be trusted to police itself. +Always in that order — *Build* is the call-chain step, the Hands are the +organ that performs it (ORGANISM.md). The Brain asks Heart for the readiness +verdict, reasons over it, and only on GREEN triggers Build. Heart never +triggers a build; the Hands never re-check readiness. Each boundary exists so +that no organ has to be trusted to police itself. ## Framework vs instance @@ -41,7 +43,7 @@ The organs split on one line that matters for adoption: pipelines. Domain facts appear only in declared config surfaces (tables and policy files, not logic), and a drift check — the {ref}`tenant firewall ` — keeps it that way. -- **Instance organs — Mind, Cortex, Memory, Gut.** Committed state, rulings, +- **Instance organs — Mind, Cortex, Memory, Gut.** Committed state, ledgers, knowledge, and shed material. These are *inherently yours*: an adopter never forks the upstream Mind, Cortex, Memory or Gut content, they create their own repos with the same documented shape. diff --git a/docs/organs/cortex.md b/docs/organs/cortex.md index 997eb8d3..5924f8f0 100644 --- a/docs/organs/cortex.md +++ b/docs/organs/cortex.md @@ -65,15 +65,18 @@ same split as **Heart ↔ vitals** and **Gut ↔ hygiene**. | Verb | What it does | |------|--------------| -| `checkin [--dry-run \| --apply] [--push \| --no-push] [--project KEY] [--skip-pull]` | **The door.** Pull every active project through its own sync CLI (streamed; one project's failure does not stop the sweep), print each project's `jobs` output verbatim where its ledger lists runs, stamp `checkin.yaml`, re-render the board, push the ledger where the rule allows, and print a summary **by project** — Now, the runs, the last entries, the `cortex.py` lines likely typed next. `--dry-run` (the default) says what it would do and reaches nothing | +| `pull [--project KEY] [--dry-run]` | **The laptop leg.** Pull every active project through its own sync CLI (streamed; one project's failure does not stop the sweep) and print each project's `jobs` output verbatim. Writes nothing; where no `local_path` exists (web, mobile) it exits 2 and says so | +| `checkin [--dry-run \| --apply] [--push \| --no-push] [--project KEY]` | **The door, on any surface.** Stamp `checkin.yaml`, re-render the board, push the ledger where the rule allows, and print a summary **by project** — Now, the runs as the ledger holds them, the last entries, the `cortex.py` lines likely typed next. Shells out to no sync CLI. `--dry-run` (the default) writes nothing | | `census [--json]` | What the Cortex is holding — per project: status, runs by state, log length, last update; the totals; the last check-in stamp | | `dashboard --check` \| `--apply` | The generated board, `dashboard.md` + `dashboard.html`. `--check` exits **1** on drift — the contract the Cortex's `dashboard_refresh.yml` runs on. The two pages are generated: never hand-edit them | | `issue [--project KEY] [--apply]` | The concise ledger block (Now, Runs, the last five) that sits at the top of each project's GitHub issue, between two markers; `--apply` writes it there through `gh` — never creates an issue | -**Checking in is one command.** `pyauto-brain cortex checkin --apply` pulls, -shows, renders and pushes on `claude/checkin-` when `gh` is logged in -and the checkout is clean on `main`, then ends with the by-project summary the -human reads back — and then records what they say with `scripts/cortex.py`. +**Checking in is two commands, one per machine.** On the laptop, +`pyauto-brain cortex pull` pulls and shows what the cluster says. Anywhere, +`pyauto-brain cortex checkin --apply --push` stamps, renders and pushes on +`claude/checkin-` when the checkout is clean on `main` with a resolvable +`origin` (no `gh` needed), then ends with the by-project summary the human +reads back — and then records what they say with `scripts/cortex.py`. ## The board diff --git a/docs/satellites.md b/docs/satellites.md index c4f1c597..927ad8b7 100644 --- a/docs/satellites.md +++ b/docs/satellites.md @@ -8,7 +8,7 @@ repos that honour the contracts your body map declares. | Category | What it is for | What the organism expects of it | |----------|----------------|--------------------------------| -| `organ` | The five organism repos themselves. | Framework identity — names survive a fork; excluded from the tenant firewall's instance-fact tokens. | +| `organ` | The eight organism repos themselves. | Framework identity — names survive a fork; excluded from the tenant firewall's instance-fact tokens. | | `library` | A source package you release. | A test suite and CI workflow Heart gates on; a row in the Brain release conductor's library set; a PyPI package the Hands release; a version floor workspaces pin against. | | `workspace` | Runnable, user-facing examples for one library. | A `run_workspace` row in `pre_build.sh` (repo, package, flags, parent library); a version pin Heart's `version_skew` compares to the installed library; required CI (smoke tests) on `main`; notebook generation from its scripts. | | `workspace_test` | Regression / smoke / parity scripts — code-heavy, doc-light. | Same `run_workspace` mechanics; scripts runnable headless in the validation pipeline; the home for cross-package and integration checks that don't belong in a library's unit tests. | diff --git a/skills/COMMANDS.md b/skills/COMMANDS.md index f57860c8..6e788e5a 100644 --- a/skills/COMMANDS.md +++ b/skills/COMMANDS.md @@ -1,6 +1,6 @@ # PyAutoBrain command surface — shared reference -The short verb commands (`/intake`, `/community`, `/feature`, `/build`, `/health`, `/bug`, +The short verb commands (`/intake`, `/batch`, `/community`, `/feature`, `/build`, `/health`, `/bug`, `/refactor`, `/workspace`, `/eyes`, `/profiling`, `/cortex`, `/hygiene`, `/docs`, `/research`, `/route`, `/brain`) are a thin, human-friendly **veneer** over the PyAutoBrain router (`bin/pyauto-brain`). This file is the shared context every command file points at, so each command body stays a few lines long. @@ -22,7 +22,7 @@ through the Brain Feature Agent. A command is a *shortcut into* the Brain, never *replacement for* it. No command file re-implements classification, planning, the readiness gate, or execution — those belong to the organs. -## The three command tiers +## The command tiers **1. Real conductors** — route straight to an existing agent in `agents/conductors/` (`AGENTS.md` is authoritative): @@ -30,6 +30,7 @@ readiness gate, or execution — those belong to the organs. | Command | Agent | Chain | |---------|-------|-------| | `/intake` | Intake Agent | `bin/pyauto-brain intake` → files a PyAutoMind prompt (**before** `start_dev`); `census`/`dashboard` = backlog inventory / `PyAutoMind/dashboard.md` | +| `/batch` | Batch Agent | `bin/pyauto-brain batch` → the BatchDecision for one unattended shift, budgeted in review minutes; proposes only — the human's approval in the slot dispatches it; `batch collect` scores what came back | | `/community` | Community Agent | `bin/pyauto-brain community` → scan/triage user-filed issues (read-only surfaces) → session drafts replies for human approval → `/start_dev_for_user` | | `/feature` | Feature Agent | `bin/pyauto-brain feature` → `start_dev` → `ship_*` | | `/bug` | Bug Agent | `bin/pyauto-brain bug` → `start_dev` → `ship_*` (health mode → vitals + Heart issues) | @@ -37,10 +38,12 @@ readiness gate, or execution — those belong to the organs. | `/workspace` | Workspace Agent | `bin/pyauto-brain workspace` → WorkspaceDecision (plan/survey example authorship) → `start_dev` → `start_workspace` → `ship_workspace` | | `/eyes` | Eyes Agent | `bin/pyauto-brain eyes` → survey/review a visualization workspace's figures; render via its `gallery_run.sh`; accepted critiques → `/intake` → `start_dev` | | `/profiling` | Profiling Agent | `bin/pyauto-brain profiling` → campaign/ingest/triage plans over the autolens_profiling workspace | -| `/cortex` | Cortex Agent | `bin/pyauto-brain cortex checkin` → the science check-in over PyAutoCortex's per-project ledgers: pull every active project through its own sync CLI, show where each run stands (its `jobs` output verbatim), re-render the board and read it back by project — Now, runs, the last entries (`census`/`dashboard`/`issue` are the verbs beside it); it records cluster facts and the human's words with `scripts/cortex.py`, never a verdict of its own; a run is submitted only on the human's ask | +| `/cortex` | Cortex Agent | `bin/pyauto-brain cortex pull` (laptop) → every active project pulled through its own sync CLI, its `jobs` output verbatim; `bin/pyauto-brain cortex checkin` (anywhere) → stamp, re-render the board, push the ledger and read it back by project — Now, runs, the last entries (`census`/`dashboard`/`issue` are the verbs beside them); it records cluster facts and the human's words with `scripts/cortex.py`, never a verdict of its own; a run is submitted only on the human's ask | | `/hygiene` | Hygiene Agent | `bin/pyauto-brain hygiene` → perf/tidy/noise/deps/docs/docstrings upkeep plans; delegates fixes to refactor/bug/feature | | `/build` | Build Agent | `bin/pyauto-brain build` → vitals faculty → Heart → PyAutoHands | | `/health` | Health Agent | `bin/pyauto-brain health` loop → vitals faculty → Heart → GREEN | +| `clone` | Clone Agent | `bin/pyauto-brain clone` → CloneDecision; a birth only under `--apply --mode lightweight-seed`, behind the human's clone-mode and repo-creation answers (skill only, no slash command) | +| `release` | Release Agent | `bin/pyauto-brain release` → the Build Agent's release mode (single gate); `rehearse`/`validate`/`nightly` beside it; a manual release stays human-authorized (skill only, no slash command) | **2. Work-type entries** — no dedicated conductor exists **yet**, so these route through the Brain dev-flow with their PyAutoMind work-type fixed. Still through @@ -105,6 +108,20 @@ call, so the Brain is not bypassed): Code chat and Codex alike; the worktree half is local-only and is reported as outstanding elsewhere. +- **`/start_bundle`** — one session, several **independent** PyAutoMind prompts + in the same repo (the dashboard's Bundles card). Every member still goes + through `/start_dev` and ships its own issue and PR, so `/prm` closes each one + out unchanged; the door only orchestrates. + +- **`sampler_pipeline`** — the ingest → prototype → profile → promote trial of a + new non-linear sampler: reason with the samplers faculty, then do each stage + as ordinary dev work through `/start_dev` → `ship_*`. Promotion to a PyAutoFit + `NonLinearSearch` is the last stage, not the first. + +- **`update_issue`** — post a progress update (commits, summary, what is left) + to the active task's GitHub issue, read from the PyAutoMind registry. The + dev-lifecycle's progress leg; `start_dev_for_user` calls it at milestones. + **5. Maintenance doors** — periodic sweeps that reason about accumulated debris and then execute their own cleanup after per-bucket human confirmation. They own no agent, but unlike the composition doors they *mutate*, so each is @@ -137,10 +154,9 @@ These are complements, not overlaps: `/repo_cleanup` never touches issues, `/issue_cleanup` never touches git, `/ci_speedup` touches neither. Neither handles **external** users' issues — that is `/community`, whose drafts stay human-approved. -Codex skills also expose the remaining public CLI agents directly: the `clone` -conductor, the `release` conductor, and the read-only `vitals`, `review`, -`memory`, and `samplers` faculties. They do not gain new -slash commands; `brain` remains Claude's low-level passthrough. +Codex skills also expose the read-only faculties directly — `vitals`, `review`, +`memory`, `sizing`, `samplers`. Faculties and the two skill-only conductors gain +no slash command; `brain` remains Claude's low-level passthrough. ## How these are installed diff --git a/skills/OPERATIONS.md b/skills/OPERATIONS.md index f9626900..558de768 100644 --- a/skills/OPERATIONS.md +++ b/skills/OPERATIONS.md @@ -11,6 +11,10 @@ gets rediscovered twice, it belongs here. ## GitHub CLI fallbacks +These are `gh` bugs on a box that *has* `gh`. Whether this session has one at +all is the other question, answered once in +[`./GITHUB_ACCESS.md`](./GITHUB_ACCESS.md). + - **`gh pr create` fails on SSH remotes.** When `origin` is an SSH URL it can refuse to resolve the repo. Fallback: `gh api repos///pulls -f title=… -f head= -f base=main -f body=…` diff --git a/skills/cortex/SKILL.md b/skills/cortex/SKILL.md index 225c310f..ba6ef06a 100644 --- a/skills/cortex/SKILL.md +++ b/skills/cortex/SKILL.md @@ -1,12 +1,13 @@ --- name: cortex -description: Check in on the science — run the PyAutoBrain Cortex Agent's one door (pull every active project through its own sync CLI, show where each run stands, re-render the board, push the ledger) and read each project's ledger back to the human — Now, the runs on the cluster, the last entries — then record what they say with the Cortex's own cortex.py verbs. Use for science runs and project ledgers; never for development tasks, which are the Mind's. +description: Check in on the science — run the PyAutoBrain Cortex Agent's two doors ('cortex pull' on the laptop, which pulls every active project through its own sync CLI and shows where each run stands; 'cortex checkin' anywhere, which stamps, re-renders and pushes the board) and read each project's ledger back to the human — Now, the runs, the last entries — then record what they say with the Cortex's own cortex.py verbs. Use for science runs and project ledgers; never for development tasks, which are the Mind's. --- # Cortex -Follow [`cortex.md`](cortex.md) exactly: it is the check-in sequence, and the -individual verbs are its appendix. The conductor records cluster facts and the +Follow [`cortex.md`](cortex.md) exactly: it is the check-in sequence — `pull` +on the laptop, `checkin` on any surface — and the individual verbs are its +appendix. The conductor records cluster facts and the human's words, never a verdict of its own: it never scores a result, never drafts a ruling, never writes a `result` or `lesson` entry the human did not say. A run is submitted only when the human asks for it in the session — then diff --git a/skills/cortex/cortex.md b/skills/cortex/cortex.md index 41cf28f9..64e0bffd 100644 --- a/skills/cortex/cortex.md +++ b/skills/cortex/cortex.md @@ -1,12 +1,18 @@ # /cortex — check in on the science (via the Brain Cortex Agent) **This is the check-in.** You have runs on a cluster; this door finds out where -they got to. It pulls every active project through that project's *own* sync -CLI, shows that CLI's `jobs` output verbatim, re-renders the board, pushes the -ledger when it is allowed to, and hands you each project's ledger back — **Now**, -the runs on the cluster, the last entries — with the `cortex.py` lines you are -most likely to type next. It records cluster facts and your words. It never -decides what a result meant. +they got to — in **two verbs, split by the machine they need**: + +- `pull` asks the cluster, through each project's *own* sync CLI, and shows + that CLI's `jobs` output verbatim. It runs **on the laptop only**: every + science root is a `local_path` out of `projects.yaml`, and it exists on one + machine. Asked anywhere else it says so, once, and stops. +- `checkin` stamps, re-renders the board, pushes the ledger when it is allowed + to, and hands you each project's ledger back — **Now**, the runs, the last + entries — with the `cortex.py` lines you are most likely to type next. It + reaches no cluster, so it works **anywhere**: web, mobile, laptop. + +It records cluster facts and your words. It never decides what a result meant. Development work is the Mind's and goes through `/intake` and `/start_dev`; this door is for what the organism is *finding out*, not what it is building. @@ -19,50 +25,54 @@ note`). Every write to one is a verb of `PyAutoCortex/scripts/cortex.py`. ## Do -### 1. Look before you pull +### 1. On the laptop, pull first ```bash -bin/pyauto-brain cortex checkin --dry-run +bin/pyauto-brain cortex pull --dry-run # names every pull; reaches nothing +bin/pyauto-brain cortex pull # pull, then jobs verbatim +bin/pyauto-brain cortex pull --project subhalo_validation ``` -Prints every project it would sweep and the exact `cd && - pull` it would run for each (and the `jobs` line where the ledger -lists runs). It reaches no cluster and writes nothing. Read it to the human — -especially if a project they expect is missing (it is missing because its -`projects.yaml` row is not `status: active` and its ledger lists no run). +Each project's own ` pull`, streamed as it comes (a pull takes +minutes; do not wrap it in anything that buffers), then — where the row has a +`jobs` verb and the ledger lists runs — its ` jobs`, printed +**verbatim**. Nothing is parsed, no state flips, nothing is written. A pull +that exits non-zero is recorded against *that* project, the sweep carries on, +and the verb exits 1. -### 2. Check in +**Not on the laptop?** `pull` exits **2** and names each missing root: *"this +is not the laptop — run `checkin` here and `pull` on the laptop."* That is the +expected answer on web and mobile, not a failure to work around. Go to step 2; +the runs you read back are the ledger's word, and say so. + +### 2. Check in — on any surface ```bash +bin/pyauto-brain cortex checkin --dry-run # what it would write bin/pyauto-brain cortex checkin --apply # push per the rule below bin/pyauto-brain cortex checkin --apply --no-push # never push bin/pyauto-brain cortex checkin --apply --project subhalo_validation -bin/pyauto-brain cortex checkin --apply --skip-pull # no pull; jobs, stamp, render ``` It runs, in order: -1. **Sync** — each project's own ` pull`, output streamed as it - comes (a pull takes minutes; do not wrap this in anything that buffers). - A pull that exits non-zero is recorded against *that* project and the sweep - carries on. -2. **Jobs** — where the row has a `jobs` verb and the ledger lists runs, the - project's own ` jobs`, printed **verbatim**. Nothing is parsed - and no state flips. -3. **Render** — the refresh stamp into `checkin.yaml` (the board's "Last +1. **Render** — the refresh stamp into `checkin.yaml` (the board's "Last check-in", red on the Pages twin once stale), then `dashboard.md` + `dashboard.html`. -4. **Push** — see the rule below. -5. **Summarise by project** — printed last, so it is what the chat sees. +2. **Push** — see the rule below. +3. **Summarise by project** — printed last, so it is what the chat sees. + +It shells out to no sync CLI. `--skip-pull` is accepted and ignored with a +notice, so an old paste still runs. ### 3. Read the summary back, project by project The last block of the output is the deliverable: one section per project — -`key — summary`, what its pull did, the jobs output, then **Now**, the -**runs** and the **last entries** as the ledger holds them. Read it to the -human as *where each project is*, in that shape: what they said they were -doing, what is on the cluster, what they last wrote down. Then stop and let -them talk. +`key — summary`, then **Now**, the **runs** and the **last entries** as the +ledger holds them. Read it to the human as *where each project is*, in that +shape: what they said they were doing, what the ledger says is on the cluster, +what they last wrote down. If you could not pull, say that the runs are the +ledger's word and the cluster was not asked. Then stop and let them talk. ### 4. Record what the human says @@ -77,7 +87,7 @@ python3 scripts/cortex.py now "" ``` - `running` and `done` are **cluster facts**: the agent may run them straight - from the `jobs` output the check-in printed, and say it did. + from the `jobs` output `pull` printed, and say it did. - A `result` or a `lesson` is written **only in the human's words, when they say it**. If you read a results file, tell the human what you see; they say what to log. Never paraphrase a result into the ledger unasked. @@ -100,13 +110,13 @@ the entry protocol, not the work. ## The push rule -`--push` is allowed only when **`gh auth status` succeeds** *and* **the Cortex -checkout is clean on `main`**. That `gh` call is a *probe*, not a GitHub -operation — a session without `gh` (a remote one, which reaches GitHub through -the `mcp__github__*` tools instead; the map is -[`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md)) simply gets `--no-push` and is -told so. Do not install `gh` to change that answer: the push wants a laptop -with a clean checkout, and a remote session has neither. +`--push` is allowed when **the Cortex checkout is clean on `main` with a +resolvable `origin`**, and it is the default. It asks git only — no `gh`, on +any surface: the probe that used to open this rule refused every session that +reaches GitHub another way (the map is +[`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md)), which left the ledger to the +merge bot. The push itself is the gate; if it fails, the summary says exactly +how and the commit is still on the branch. When it pushes it cuts `claude/checkin-` from a fresh `origin/main`, commits the changed paths **explicitly**, and pushes. If @@ -126,8 +136,9 @@ and nothing for the human to merge. **Never `main` directly, never `--force`.** entry is the human's words, verbatim, on their ask. - **Never edit a ledger by hand.** Every write is a `cortex.py` verb; the script refuses an edit that would not read back. -- **Only the project's own CLI reaches a cluster.** The door adds no SSH of - its own, and `--dry-run` reaches nothing at all. +- **Only the project's own CLI reaches a cluster.** `pull` adds no SSH of its + own, `checkin` reaches no cluster at all, and either `--dry-run` reaches + nothing. - **The door runs once and ends.** No timer, no subscription, no cron, no loop — you check in, you report, you stop. - **The door names the assistant, never reads it.** No assistant page is @@ -144,7 +155,8 @@ checkout. | Verb | Answers | |------|---------| -| `checkin [--dry-run\|--apply] [--push\|--no-push] [--project KEY] [--skip-pull]` | Where is my science? The whole sequence above. Exit **1** = a pull failed or the tree does not check | +| `pull [--project KEY] [--dry-run]` | What does the cluster say? Each project's own pull, then its `jobs` output verbatim. The laptop only. Exit **1** = a pull failed · **2** = no project's `local_path` is on this machine | +| `checkin [--dry-run\|--apply] [--push\|--no-push] [--project KEY]` | Where is my science? Stamp, render, push, read each ledger back. Any surface. Exit **1** = the tree does not check | | `census [--json]` | What is the Cortex holding? Per project: status, runs by state, log length, last update; the totals; the last check-in stamp | | `dashboard --check` | Are the committed pages current? Exit **1** = stale (the refresh workflow's contract) | | `dashboard --apply` | Regenerate `dashboard.md` + `dashboard.html` — never hand-edit those two | diff --git a/skills/health/health.md b/skills/health/health.md index c4fc9467..5e9979bf 100644 --- a/skills/health/health.md +++ b/skills/health/health.md @@ -30,10 +30,8 @@ Shared routing context: `PyAutoBrain/skills/COMMANDS.md`. - **`/health worktrees`** → follow the worktree dashboard procedure in `PyAutoHeart/skills/worktree_status/reference.md`. -`/health` is the **only** health command. The former `/health_check`, -`/pyauto-status`, `/pyauto-status-full`, and `/worktree_status` are retired as -top-level commands and live on as the `check`, `status`, `full`, and -`worktrees` legs above — the door is the Brain, the procedures are Heart's. +`/health` is the **only** health command — the door is the Brain, the +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 diff --git a/skills/intake/intake.md b/skills/intake/intake.md index c6b1e6c1..001ede16 100644 --- a/skills/intake/intake.md +++ b/skills/intake/intake.md @@ -84,8 +84,8 @@ dev workflow (issue, branch, plan). Do not bypass the Brain. (then regenerate the dashboard and commit it with the change, per step 4). - `bin/pyauto-brain intake reconcile [prefix]` — ranks backlog (`draft/`) prompts that look already-shipped (cross-referenced against the `complete/` - records — the sole completion ledger since `complete.md` retired, #81 — and `active/`; a stale - hand-set `Status:` is a signal, never proof). Always read-only: verify each + records — the sole completion ledger — and `active/`; a stale hand-set + `Status:` is a signal, never proof). Always read-only: verify each suspect against the target repo's git log / merged PRs, then retire it to the `complete/` archive by hand (it is already done). - `bin/pyauto-brain intake reconcile --repo [prefix]` — **also** reads diff --git a/skills/issue_cleanup/issue_cleanup.md b/skills/issue_cleanup/issue_cleanup.md index 969ec711..10228484 100644 --- a/skills/issue_cleanup/issue_cleanup.md +++ b/skills/issue_cleanup/issue_cleanup.md @@ -24,11 +24,7 @@ reply* — this skill never touches those, it routes them there); `$create-issue and `$update-issue` (single-issue primitives); `$hygiene` (code-quality debt, not the tracker). -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Why this needs care diff --git a/skills/issue_cleanup/reference.md b/skills/issue_cleanup/reference.md index c0f3d0ea..ae2bdc2a 100644 --- a/skills/issue_cleanup/reference.md +++ b/skills/issue_cleanup/reference.md @@ -5,11 +5,7 @@ holds the collection commands, the record header taxonomy, the evidence rules, the dashboard layout, the per-bucket execution recipes, the recap, and the execution-environment fallback. -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Collect open issues diff --git a/skills/prm/prm.md b/skills/prm/prm.md index 2676f1dd..8a8ba16a 100644 --- a/skills/prm/prm.md +++ b/skills/prm/prm.md @@ -172,9 +172,24 @@ Typing `/prm` authorized all of this; the only questions are the guards in step 2. **Issue** — post the "Shipped" comment (template: `../ship_library/reference.md` → "Issue comments + Mind state"), then close it. `gh issue close` is broken in this gh; use the REST path. -3. **Mind: `active/` → `complete/`** — draft the completion body, then - `lifecycle.py record … --prompt --apply`. A *path* there - silently no-ops, so verify all three effects rather than the exit code. +3. **Mind: `active/` → `complete/`** — draft the completion body, then one + verb does the whole Mind-side close-out — the record, the prompt's + removal, the `active.md` row (and any `parked.md`/`planned.md` pointer), + the shadow row when the tier is `notify`, and `complete/index.md`: + + ```bash + python3 scripts/lifecycle.py close --date \ + --from-file --pr [--tier notify --gate "" \ + --action --stage <1|2>] # dry run: prints every step + python3 scripts/lifecycle.py close … --apply # then does them + ``` + + Read the dry run before `--apply`: it names the record path, the file it + removes, the entry it drops and every cross-reference you must repoint + (`draft/`, `active/`, `epics.md`, the registries — it never rewrites those + itself). It refuses a record that already exists and a slug it cannot + resolve; `--prompt ` names the prompt when the slug does + not. `lifecycle.py record …` remains underneath for the record alone. **Record the scope you merged, not the scope you filed.** On a partial merge, record what shipped and re-file the remainder as a fresh @@ -220,18 +235,11 @@ Typing `/prm` authorized all of this; the only questions are the guards in step → `merged-unchanged` / `merged-after-substantive-change`. `not-merged` is what gets recorded when `/prm` stopped on a guard (step 6) and never reached the question — never a guess at what the answer would have been. - 5. **Append**, inside the Mind commit sub-step 4 is about to make: - - ```bash - python3 scripts/lifecycle.py shadow-row \ - --date --task " (# …)" --tier notify \ - --gate "" --action --stage <1|2> --apply - ``` - - Without `--apply` it prints the row and the new count line and writes - nothing — that is how you check the cells before committing to them. - The row then rides the same commit and push as the record and the - dashboard; it is never a commit of its own. + 5. **Append** — the `--tier notify --gate "" --action + --stage <1|2>` flags on the `close` verb above do it (`shadow-row` is + the verb underneath). The dry run prints the row and the new count line + before anything is written; the row rides the same commit and push as + the record and the dashboard, never a commit of its own. 6. **Name it in the ledger** (sub-step 7): "shadow row appended, count N/40". diff --git a/skills/repo_cleanup/SKILL.md b/skills/repo_cleanup/SKILL.md index 065ac3aa..9b5d6961 100644 --- a/skills/repo_cleanup/SKILL.md +++ b/skills/repo_cleanup/SKILL.md @@ -36,11 +36,7 @@ but this also mutates); post-merge cleanup in `CLAUDE.md` (once per shipped task this covers residue when that flow is skipped); the start_dev branch survey (task start — this is between-tasks hygiene). -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Safety principles (non-negotiable) diff --git a/skills/repo_cleanup/reference.md b/skills/repo_cleanup/reference.md index 9e30d2f3..66980ece 100644 --- a/skills/repo_cleanup/reference.md +++ b/skills/repo_cleanup/reference.md @@ -4,11 +4,7 @@ Factored out of `SKILL.md`. The body is authoritative for the flow; this holds the audit commands, the dashboard layout, the per-bucket execution recipes, the recap, and the execution-environment fallback. -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Audit canonical checkouts diff --git a/skills/ship_library/reference.md b/skills/ship_library/reference.md index c2abaa42..d559b2f0 100644 --- a/skills/ship_library/reference.md +++ b/skills/ship_library/reference.md @@ -4,11 +4,7 @@ Factored out of `ship_library.md`. The body skill is authoritative for the flow; this file holds the verbatim PR format, the API-Changes rules, and the workspace-impact analysis. -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Writing the `## API Changes` section (judgement — stays in the reasoning model) @@ -174,7 +170,7 @@ and `/review_release` clears it once a release has actually published. **Shipped (option iii passed):** offer to merge the library PR (`gh pr merge --merge --auto`), post a "Shipped" comment (PRs, summary, optional session notes), then record completion — the dated record **is** the -ledger (issues #71/#81; the monolithic `complete.md` was retired 2026-07-16): +ledger (issues #71/#81): - **Draft the rich completion body** to a temp file — `## `, `issue`, `completed: `, `library-pr:`, any uncleared `pending-release:` carried over from the `active.md` row, then the summary/traps/notes bullets. diff --git a/skills/ship_library/ship_library.md b/skills/ship_library/ship_library.md index f6d2c4d5..689ead80 100644 --- a/skills/ship_library/ship_library.md +++ b/skills/ship_library/ship_library.md @@ -15,11 +15,7 @@ the organ boundary, the readiness gate, and the execution-environment model. PR format, the execution contract, and the impact analysis are in [`reference.md`](reference.md). -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Steps diff --git a/skills/ship_workspace/reference.md b/skills/ship_workspace/reference.md index e06063b3..c28b0965 100644 --- a/skills/ship_workspace/reference.md +++ b/skills/ship_workspace/reference.md @@ -3,11 +3,7 @@ Factored out of `ship_workspace.md`. The body skill is authoritative for the flow; this file holds the PR format, the merge gate, and the issue/Mind formats. -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## PR body format diff --git a/skills/ship_workspace/ship_workspace.md b/skills/ship_workspace/ship_workspace.md index 56617e9f..2b237dfe 100644 --- a/skills/ship_workspace/ship_workspace.md +++ b/skills/ship_workspace/ship_workspace.md @@ -15,11 +15,7 @@ entry point, not an agent. Read [`../WORKFLOW.md`](../WORKFLOW.md) for the organ boundary, readiness gate and execution-environment model; PR format, merge gate and issue/Mind formats are in [`reference.md`](reference.md). -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Steps diff --git a/skills/start_dev/reference.md b/skills/start_dev/reference.md index b760488b..b7994301 100644 --- a/skills/start_dev/reference.md +++ b/skills/start_dev/reference.md @@ -4,11 +4,7 @@ Long-form templates and procedures factored out of `start_dev.md` to keep the primary skill concise. The body skill is authoritative for the flow; this file holds the verbatim formats it points at. -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Issue body diff --git a/skills/start_dev/start_dev.md b/skills/start_dev/start_dev.md index eb444c4f..91d8b7c8 100644 --- a/skills/start_dev/start_dev.md +++ b/skills/start_dev/start_dev.md @@ -16,11 +16,7 @@ Opus too, dropping to Sonnet only for the really simple mechanical `ship_*` / `pre_build` recipes), and the Mind registry paths used below. -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Usage diff --git a/skills/start_dev_for_user/reference.md b/skills/start_dev_for_user/reference.md index 9dd71260..7018da5c 100644 --- a/skills/start_dev_for_user/reference.md +++ b/skills/start_dev_for_user/reference.md @@ -4,11 +4,7 @@ Factored out of `start_dev_for_user.md` (read by repo path `PyAutoBrain/skills/start_dev_for_user/reference.md`). Holds the tone rules, comment templates, registry formats, and the forward-compatibility note. -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Tone rules (every comment on a `user-facing: true` task) diff --git a/skills/start_dev_for_user/start_dev_for_user.md b/skills/start_dev_for_user/start_dev_for_user.md index dbf01cca..5a4443e5 100644 --- a/skills/start_dev_for_user/start_dev_for_user.md +++ b/skills/start_dev_for_user/start_dev_for_user.md @@ -15,11 +15,7 @@ the organ boundary, the Feature Agent, Memory consultation and the execution-environment model. Tone rules, comment templates and registry formats are in [`reference.md`](reference.md) (`PyAutoBrain/skills/start_dev_for_user/reference.md`). -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Usage diff --git a/skills/start_library/start_library.md b/skills/start_library/start_library.md index 4a5b8efc..c12201af 100644 --- a/skills/start_library/start_library.md +++ b/skills/start_library/start_library.md @@ -9,11 +9,7 @@ Workflow entry point — the worktree/branch setup is the dev workflow's own state is **Mind**. Read [`../WORKFLOW.md`](../WORKFLOW.md) for the organ boundary, the worktree helpers, the execution-environment model, and the registry paths. -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Steps diff --git a/skills/start_workspace/reference.md b/skills/start_workspace/reference.md index 0ba36c3d..d0afbb0f 100644 --- a/skills/start_workspace/reference.md +++ b/skills/start_workspace/reference.md @@ -3,11 +3,7 @@ Factored out of `start_workspace.md`. The body skill is authoritative for the flow; this file holds the verbatim impact-report and registry formats. -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Linked-mode API-change impact diff --git a/skills/start_workspace/start_workspace.md b/skills/start_workspace/start_workspace.md index e8ad050f..2eea4b43 100644 --- a/skills/start_workspace/start_workspace.md +++ b/skills/start_workspace/start_workspace.md @@ -11,11 +11,7 @@ Workflow entry point — worktree/branch setup is the dev workflow's own helpers, execution-environment model, and registry paths. Verbose formats live in [`reference.md`](reference.md). -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Steps diff --git a/skills/update_issue/SKILL.md b/skills/update_issue/SKILL.md index cb97d05c..985c546e 100644 --- a/skills/update_issue/SKILL.md +++ b/skills/update_issue/SKILL.md @@ -10,11 +10,7 @@ is part of the development cycle (the `start_*` → `ship_*` lifecycle; `start_dev_for_user` calls it at milestones). It reads the PyAutoMind registry to find the active issue. Organ boundary: [`../WORKFLOW.md`](../WORKFLOW.md). -> **GitHub surface.** The `gh` commands below name the *operation*, not -> necessarily the command: a Claude Code remote session has no `gh` and -> reaches GitHub through the `mcp__github__*` tools instead. Probe once -> (`command -v gh`) and translate via -> [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). +> No `gh` on a remote session — map each `gh` step via [`../GITHUB_ACCESS.md`](../GITHUB_ACCESS.md). ## Usage diff --git a/skills/vitals/SKILL.md b/skills/vitals/SKILL.md index 58b197f8..cf572357 100644 --- a/skills/vitals/SKILL.md +++ b/skills/vitals/SKILL.md @@ -7,4 +7,7 @@ description: Read and explain the authoritative PyAutoHeart readiness verdict th Read [`../../agents/faculties/vitals/AGENTS.md`](../../agents/faculties/vitals/AGENTS.md) completely, then run `bin/pyauto-brain vitals` in the documented mode. Return -the verdict and reasons without mutating or bypassing Heart. +the verdict and reasons without mutating or bypassing Heart. Without the Heart +CLI (every web/mobile session) it reads the Heart's published Pages board +instead; `--scope [,]` gives the verdict for the repos a branch +actually touches beside the organism-wide one. diff --git a/tests/fixtures/heart_pages/badge.json b/tests/fixtures/heart_pages/badge.json new file mode 100644 index 00000000..73126995 --- /dev/null +++ b/tests/fixtures/heart_pages/badge.json @@ -0,0 +1,6 @@ +{ + "schemaVersion": 1, + "label": "heart", + "message": "RED 2 blockers", + "color": "red" +} diff --git a/tests/fixtures/heart_pages/board.json b/tests/fixtures/heart_pages/board.json new file mode 100644 index 00000000..866f026c --- /dev/null +++ b/tests/fixtures/heart_pages/board.json @@ -0,0 +1,33 @@ +{ + "schema_version": 3, + "generated": "2026-09-17 06:12 UTC", + "blockers": [ + { + "text": "repob_workspace: nightly smoke red", + "severity": "red", + "repo": "repob_workspace", + "repo_url": "https://example.invalid/repob_workspace", + "run_url": "https://example.invalid/run/9", + "prompt": "/bug Heart board: repob_workspace nightly smoke red", + "command": null + }, + { + "text": "RepoA: install verification not run", + "severity": "stale", + "repo": "RepoA", + "repo_url": "https://example.invalid/RepoA", + "run_url": null, + "prompt": "/health run `pyauto-heart verify_install --report-json`", + "command": "pyauto-heart verify_install --report-json" + }, + { + "text": "release validation missing for current source", + "severity": "stale", + "repo": null, + "repo_url": null, + "run_url": null, + "prompt": "/health re-run release validation", + "command": "pyauto-heart tick" + } + ] +} diff --git a/tests/test_cortex_conductor.py b/tests/test_cortex_conductor.py index 32f84a1c..21f97e98 100644 --- a/tests/test_cortex_conductor.py +++ b/tests/test_cortex_conductor.py @@ -87,6 +87,16 @@ def _run(args, cwd=None, env=None): """ +def wire_missing(root: Path, tmp_path: Path): + """Point every `local_path` at a directory that is not there — the web and + mobile surface, where a science root is a laptop path and nothing else.""" + text = (root / "projects.yaml").read_text(encoding="utf-8") + for key in re.findall(r"^([a-z][a-z0-9_]*):$", text, re.M): + text = text.replace(f"local_path: /tmp/{key}\n", + f"local_path: {tmp_path / 'not-here' / key}\n") + (root / "projects.yaml").write_text(text, encoding="utf-8") + + def wire_cli(root: Path, tmp_path: Path, fail=(), jobs="3002_[0-3] ral RUNNING"): """Point every `local_path` of the copied fixture at a directory holding a fake `hpc/sync` that echoes — so `--apply` pulls something that exists @@ -187,7 +197,13 @@ def test_one_resume_chip_per_active_project_and_no_other_chips(skeleton): "nothing until I say.") in page # `assistant: none` names no assistant assert ("and then /tmp/single/NOTES.md; tell me where I left off" in page) - assert "since the last check-in (2026-09-02T09:00Z)" in page + # two lines, because the two halves do not run on the same machine + assert ("/cortex — on the laptop: `pyauto-brain cortex pull` — pull every " + "active science project through its own sync CLI and show me " + "where each run stands." in page) + assert ("/cortex — anywhere: `pyauto-brain cortex checkin --apply --push` " + "— stamp, re-render and push the board since the last check-in " + "(2026-09-02T09:00Z), then read me the by-project summary." in page) assert "Record nothing about results — I will tell you what to log." in page assert "### Last check-in: 2026-09-02T09:00Z" in page assert "retire" not in page.lower().replace("retired", "") @@ -263,7 +279,8 @@ def test_the_html_twin_wears_the_theme_with_real_copy_buttons(skeleton): assert _cortex._theme_css("cortex") in html assert html.count('