diff --git a/AGENTS.md b/AGENTS.md index 2b4554fb..7f26f21c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -30,88 +30,21 @@ Call chain (always this order): **Brain → Heart (gate) → Build (execute)**. Generated from `PyAutoMind/repos.yaml` + `PyAutoBrain/ORGANISM.md`; edit there, then run `python3 PyAutoMind/scripts/repos_sync.py --write`. -## What this repo is - -PyAutoBrain is the **reasoning layer** of the PyAuto ecosystem as it grows into a -software organism. It figures out *how* work should be done and coordinates the -organs that do it. It hosts specialist **reasoning agents** — each a documented -role plus a deterministic entrypoint script — that read intent (from PyAutoMind -and the developer), reason about it, and drive the health/execution machinery at -the right points. - -PyAutoBrain owns **no state, no health checks, and no execution mechanics**. It -only *reasons* and *delegates*: it asks PyAutoHeart whether the organism is -healthy, decides whether and how to proceed, and tells PyAutoHands to execute -when it should. - -## The organism - -The organs, their boundaries, and the `Brain → Heart (gate) → Build (execute)` -call chain are defined **once** in [`ORGANISM.md`](ORGANISM.md) — this repo -hosts that canonical page; every other organ links to it. In one line: the -Mind decides *what*, the Brain (this repo) figures out *how*, the Heart gates, -the Hands build, Memory knows what the science says. - -## Brain agents consult one another (a society of agents) - -Brain agents are not limited to driving organs — they can **consult each other**. -The canonical example is the **Build Agent**, which does not query Heart directly: -it consults the **vitals faculty**, and only the vitals faculty talks to the Heart -organ. So the Build Agent's full chain is: - -``` -Mind → Build Agent → vitals faculty → Heart → GREEN/YELLOW/RED - → Build Agent → Build (execute) -``` - -The consult graph is a DAG (see [`ORGANISM.md`](ORGANISM.md)): conductors -consult faculties; faculties read their sensor organ; a conductor never -consults another conductor — if it wants one's opinion, that opinion should be -a faculty. The Build Agent is the reusable template for this pattern. - -How much human checkpointing a workflow run needs is defined once in -[`AUTONOMY.md`](AUTONOMY.md) — the autonomy contract mapping each Mind-prompt -`Autonomy:` level to behaviour at every checkpoint. - -## Specialist reasoning agents - -Agents live in **two tiers** under `agents/`, distinguished by one question — -*does it act, or only opine?* - -- **Conductors** (`agents/conductors//`) — front-door agents a human - **drives**. They *decide **and** act*, delegating execution to the organs. - They have side effects in the world (a plan driven into dev, a build, a - release). This is the small, curated set of things you invoke and converse - with. -- **Faculties** (`agents/faculties//`) — read-only reasoning capabilities - the conductors **consult**. They *only opine* — return a judgment and stop; - they never dispatch or mutate. They are *sinks* in the consult graph - (everything reaches into them; they reach out only to their sensor organ). Not - chat-first surfaces, though they stay runnable for a quick read. - -The rule of thumb: **keep the conductor set small and human-meaningful; let -faculties multiply behind them.** A side-effecting decider is a conductor; a -side-effect-free opinion is a faculty. - -Each agent is a directory with an `AGENTS.md` (what it reasons about + how to run -it) and a deterministic entrypoint script (`*.sh` / `*.py`) — the part CI and -humans invoke identically, so behaviour isn't re-derived from prose each time. - -New agents are added on **demonstrated need, never for symmetry**. Place by -tier: a side-effecting decider you drive → `agents/conductors//`; a -read-only opinion the conductors consult → `agents/faculties//`. Follow -the Build Agent's shape (a concise `AGENTS.md` opening with its `Tier:` line, a -deterministic entrypoint, and a capability audit of any organ it drives — the -Feature Agent's `MIND_TAXONOMY.md` is that audit for the PyAutoMind/PyAutoMemory -surface). Keep the conductor set small; prefer a faculty when the new thing -only reasons. - -**Scaling invariant.** The per-agent roster is not maintained here. Adding an -agent touches only `bin/pyauto-brain` (the registry) and the agent's own -directory (`agents///` with its `AGENTS.md` + entrypoint). The verb -tables below are **generated** from that registry by -`bin/install.sh --write-agents-surface` — never hand-edit this file's roster, -and read each agent's own `AGENTS.md` for its full role. +## Working here + +Brain plans and coordinates; it owns no task state, health checks or release +mechanics. Mind owns intent/state, Heart gates readiness, Hands executes releases. +Use conductors for decisions and actions; faculties return read-only judgments. +The consultation graph is a DAG: conductors consult faculties, not conductors. +See [ORGANISM.md](ORGANISM.md) for boundaries and [AUTONOMY.md](AUTONOMY.md) +for checkpoint rules. Add a role only on demonstrated need. + +For development use [skills/WORKFLOW.md](skills/WORKFLOW.md), then the invoked +skill. Read only its current step and applicable environment. Reuse unchanged +instructions already loaded; use [context discipline](skills/CONTEXT.md). +For new agents or command wiring, read [agent reference](docs/agent_reference.md). +Add registry entries in `bin/pyauto-brain` and the agent directory; regenerate +this command table with `bin/install.sh --write-agents-surface`, never by hand. ## Running @@ -121,42 +54,38 @@ and read each agent's own `AGENTS.md` for its full role. markers — edit the registry there and re-run. Checked by `PyAutoBrain/bin/install.sh --check-agents-surface`. --> -The PyAuto **command surface** — every agent verb, runnable on any tool (Claude, -Codex, Cursor; CLI or web) as `bin/pyauto-brain `. This block lives once in -**PyAutoBrain**'s auto-loaded AGENTS.md, which is present in every session, so the -full verb set is always in context — no per-organ copy needed. Invoking a verb -runs its entrypoint here in PyAutoBrain. On Claude Code the same verbs are also -the `/` slash commands. +Run from the Brain checkout. Read the selected agent's `AGENTS.md` only when +invoking it; `bin/pyauto-brain help ` exposes its full contract. **Conductors** — front doors you drive (decide *and* act): | Verb | Purpose | Entrypoint | |------|---------|------------| -| `intake` | Conceive a task: turn raw input into a formal, headed PyAutoMind prompt (files it; never starts dev) | `bin/pyauto-brain intake` | -| `batch` | Compose one unattended shift: the BatchDecision, planned against the slot's REVIEW-MINUTE budget rather than a task count — proposes, never dispatches; 'batch collect' scores what came back into the review packet and stamps the batch record | `bin/pyauto-brain batch` | -| `community` | The ears — the organism's receptive function: scan/triage the Discussions hub where users ask (PyAutoMind/policy/community_surface.md) plus user-filed GitHub issues + PRs and review requests across the repos; drafts stay human-gated, dev work routes via start_dev_for_user (never posts) | `bin/pyauto-brain community` | -| `feature` | Reason over PyAutoMind feature tasks: select, size, phase, plan for start_dev | `bin/pyauto-brain feature` | -| `bug` | The immune system: classify a bug/regression/Heart finding, locate the fix, plan the repair | `bin/pyauto-brain bug` | -| `refactor` | The renewal function: plan behaviour-preserving restructuring — RefactorDecision; default-safe under --auto | `bin/pyauto-brain refactor` | -| `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 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` | -| `release` | Release door → the Build Agent release mode (single gate); 'release rehearse'/'release validate' drive release validation; 'release nightly' is the scheduled-nightly driver | `bin/pyauto-brain release` | -| `health` | The organism's clinician: run the health loop with a human, dispatch by dispatch, toward green | `bin/pyauto-brain health` | +| `intake` | File classified prompts; never start development | `bin/pyauto-brain intake` | +| `batch` | Propose a review-budgeted batch; collect its results | `bin/pyauto-brain batch` | +| `community` | Triage community threads; human-approved replies and development handoffs | `bin/pyauto-brain community` | +| `feature` | Select, size and plan features | `bin/pyauto-brain feature` | +| `bug` | Classify regressions and plan repairs | `bin/pyauto-brain bug` | +| `refactor` | Plan behavior-preserving restructuring | `bin/pyauto-brain refactor` | +| `workspace` | Plan or survey examples and tutorials | `bin/pyauto-brain workspace` | +| `eyes` | Survey figures and route accepted critiques | `bin/pyauto-brain eyes` | +| `profiling` | Plan campaigns; ingest results; triage profiling drift | `bin/pyauto-brain profiling` | +| `cortex` | Pull science runs and record human checkins | `bin/pyauto-brain cortex` | +| `hygiene` | Prioritize upkeep and delegate fixes | `bin/pyauto-brain hygiene` | +| `clone` | Plan assistant births or synchronize generic files | `bin/pyauto-brain clone` | +| `build` | Consult vitals and coordinate Hands execution | `bin/pyauto-brain build` | +| `release` | Coordinate release rehearsal, validation and nightly execution | `bin/pyauto-brain release` | +| `health` | Assess health and route repairs | `bin/pyauto-brain health` | **Faculties** — read-only opinions the conductors consult (also runnable): | Verb | Purpose | Entrypoint | |------|---------|------------| -| `vitals` | Read-only: read the Heart's pulse — the PyAutoHeart readiness verdict (consulted by the conductors) | `bin/pyauto-brain vitals` | -| `review` | Read-only: prepare the branch ReviewSurface — the reviewing agent maps it to CLEAN/FINDINGS/BLOCKED (the ship gate's review leg) | `bin/pyauto-brain review` | -| `memory` | Read-only: recall what the organism knows — a cited digest over PyAutoMemory, autolens_assistant and Mind history | `bin/pyauto-brain memory` | -| `samplers` | Read-only: the motor faculty — SamplerSurface digest over the sampler script tiers, the PyAutoFit search catalogue and the benchmark record | `bin/pyauto-brain samplers` | -| `sizing` | Read-only: the SizingSurface — a difficulty estimate for a PyAutoMind prompt; the single heuristic the intake and feature conductors both consult | `bin/pyauto-brain sizing` | +| `vitals` | Read authoritative Heart readiness | `bin/pyauto-brain vitals` | +| `review` | Prepare independent CLEAN/FINDINGS/BLOCKED branch review | `bin/pyauto-brain review` | +| `memory` | Recall cited scientific and task history | `bin/pyauto-brain memory` | +| `samplers` | Inspect sampler coverage, tiers and benchmarks | `bin/pyauto-brain samplers` | +| `sizing` | Estimate task difficulty | `bin/pyauto-brain sizing` | Like the other PyAuto repos, PyAutoBrain runs from its checkout (no pip install); @@ -183,65 +112,18 @@ nothing has set it up — this block is what does. `gh` operation onto its tool and is the one full page on the subject. -## The command surface (Brain implicit) - -The verb table above is the machinery; humans drive it through short commands -(`/intake`, `/feature`, …) in Claude Code, or discoverable skills in Claude and -Codex. The Brain stays **implicit** — you type a verb, or plain natural language -via `/route`, and it routes to the right agent; normal usage never says -"PyAutoBrain". A few commands are compositions rather than single agents: -`/docs` and `/research` route through the dev-flow with their PyAutoMind -work-type fixed (no dedicated conductor — added only on demonstrated need, never -for symmetry); `/prm` composes the -end-of-task close-out (CI green → merge → issue closed → Mind `active/` → -`complete/` → dashboard reconciled and regenerated → worktree and local branches -removed); `/brain -` is the raw passthrough. Every command routes **through** the Brain; -none replaces it. - -The morning routine is not a command at all: the **Brain board** -(`board/_board.py`, published to the Brain's GitHub Pages URL each morning by -`brain_board.yml`) carries what `/wake_up` used to assemble — overnight runs, -readiness, community, resume, upkeep — as one-tap 📋 payloads, and -`bin/morning.sh` is the local sync/clean leg you run in a terminal. -`/wake_up` remains only as the fallback door when the board is unreachable. - -The command bodies live in `skills//.md`; thin `SKILL.md` wrappers -make the same canonical workflows discoverable to skill-aware harnesses. -`bin/install.sh` installs both surfaces without duplicating their bodies. Shared -architecture prose is in [`skills/COMMANDS.md`](skills/COMMANDS.md); the -work-type taxonomy the router uses is `PyAutoMind/ROUTING.md`. - -## Chat register: concise by default - -The default register for **chat replies** is concise — every harness and every -session (Claude Code CLI, web, mobile; Codex; Cursor). A reply is the smallest -thing that answers the question and says what changed. It is not a report on the -work. - -- **Answer first.** Lead with the answer, the verdict, or what you did. No - preamble, no restatement of the request, no summary of the summary. -- **A few lines is the default length.** One line is a good answer. Prose - paragraphs, file-by-file inventories and "what I did / why / next steps" - scaffolding are opt-in, not the baseline. -- **Don't narrate the work.** Skip the tool-by-tool commentary, the list of - files read, and any recap of a diff the human can read on the branch or PR. -- **Link, don't paste.** Point at the file, the issue, the PR, the prompt under - `PyAutoMind/draft/`; quote only the lines being discussed. - -Four things are never compressed: a **plan awaiting approval**, a **decision -surface** a human must judge, a **failure or blocker** (say exactly what broke -and where), and anything the human **asked to have explained**. Brevity is not a -licence to drop the detail a decision needs. +## Commands and communication -The escape hatch is a word — "expand", "in full", "explain" — and it applies to -that reply, not the session; the register comes back on the next turn. +Users invoke verbs or natural language; Brain stays implicit. `/docs` and +`/research` fix a dev work type; `/prm` merges and closes out a task; `/brain` +is a raw passthrough. Canonical bodies are `skills//.md`, discovered +through thin `SKILL.md` wrappers. The morning surface is `board/`; local sync +uses `bin/morning.sh`. `/wake_up` is the fallback when the board is unavailable. -Agent output is not chat and keeps its defined shape: a `*Decision`, a -`ReviewSurface`, a vitals verdict, the board digest are structured artefacts -this register does not trim. It governs the prose around them. On Claude Code -the same default can also be pinned per-tool with an output style, but the -register above is the portable one — it travels with the repo to every harness. +Answer first, briefly; link instead of pasting. Expand plans awaiting approval, +decision surfaces, failures/blockers and requested explanations enough to judge. +Keep structured decisions, review surfaces and verdicts complete. These rules +apply to surrounding chat, not to the defined artifact schema. ## Never rewrite history diff --git a/bin/install.sh b/bin/install.sh index ef183dff..b9afe202 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -95,12 +95,8 @@ agents_surface_block() { markers — edit the registry there and re-run. Checked by `PyAutoBrain/bin/install.sh --check-agents-surface`. --> -The PyAuto **command surface** — every agent verb, runnable on any tool (Claude, -Codex, Cursor; CLI or web) as `bin/pyauto-brain `. This block lives once in -**PyAutoBrain**'s auto-loaded AGENTS.md, which is present in every session, so the -full verb set is always in context — no per-organ copy needed. Invoking a verb -runs its entrypoint here in PyAutoBrain. On Claude Code the same verbs are also -the `/` slash commands. +Run from the Brain checkout. Read the selected agent's `AGENTS.md` only when +invoking it; `bin/pyauto-brain help ` exposes its full contract. **Conductors** — front doors you drive (decide *and* act): diff --git a/bin/pyauto-brain b/bin/pyauto-brain index acb2909e..80408b6e 100755 --- a/bin/pyauto-brain +++ b/bin/pyauto-brain @@ -79,26 +79,26 @@ declare -A AGENT_SCRIPT=( [sizing]="$FACULTIES_DIR/sizing/sizing.sh" ) declare -A AGENT_DESC=( - [intake]="Conceive a task: turn raw input into a formal, headed PyAutoMind prompt (files it; never starts dev)" - [batch]="Compose one unattended shift: the BatchDecision, planned against the slot's REVIEW-MINUTE budget rather than a task count — proposes, never dispatches; 'batch collect' scores what came back into the review packet and stamps the batch record" - [community]="The ears — the organism's receptive function: scan/triage the Discussions hub where users ask (PyAutoMind/policy/community_surface.md) plus user-filed GitHub issues + PRs and review requests across the repos; drafts stay human-gated, dev work routes via start_dev_for_user (never posts)" - [feature]="Reason over PyAutoMind feature tasks: select, size, phase, plan for start_dev" - [bug]="The immune system: classify a bug/regression/Heart finding, locate the fix, plan the repair" - [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 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)" - [build]="Coordinate execution: consult the vitals faculty, then delegate to PyAutoHands" - [release]="Release door → the Build Agent release mode (single gate); 'release rehearse'/'release validate' drive release validation; 'release nightly' is the scheduled-nightly driver" - [health]="The organism's clinician: run the health loop with a human, dispatch by dispatch, toward green" - [vitals]="Read-only: read the Heart's pulse — the PyAutoHeart readiness verdict (consulted by the conductors)" - [review]="Read-only: prepare the branch ReviewSurface — the reviewing agent maps it to CLEAN/FINDINGS/BLOCKED (the ship gate's review leg)" - [memory]="Read-only: recall what the organism knows — a cited digest over PyAutoMemory, autolens_assistant and Mind history" - [samplers]="Read-only: the motor faculty — SamplerSurface digest over the sampler script tiers, the PyAutoFit search catalogue and the benchmark record" - [sizing]="Read-only: the SizingSurface — a difficulty estimate for a PyAutoMind prompt; the single heuristic the intake and feature conductors both consult" + [intake]="File classified prompts; never start development" + [batch]="Propose a review-budgeted batch; collect its results" + [community]="Triage community threads; human-approved replies and development handoffs" + [feature]="Select, size and plan features" + [bug]="Classify regressions and plan repairs" + [refactor]="Plan behavior-preserving restructuring" + [workspace]="Plan or survey examples and tutorials" + [eyes]="Survey figures and route accepted critiques" + [cortex]="Pull science runs and record human checkins" + [profiling]="Plan campaigns; ingest results; triage profiling drift" + [hygiene]="Prioritize upkeep and delegate fixes" + [clone]="Plan assistant births or synchronize generic files" + [build]="Consult vitals and coordinate Hands execution" + [release]="Coordinate release rehearsal, validation and nightly execution" + [health]="Assess health and route repairs" + [vitals]="Read authoritative Heart readiness" + [review]="Prepare independent CLEAN/FINDINGS/BLOCKED branch review" + [memory]="Recall cited scientific and task history" + [samplers]="Inspect sampler coverage, tiers and benchmarks" + [sizing]="Estimate task difficulty" ) # Conductors are the front doors a human drives; faculties are consulted (and # runnable read-only). Both are dispatchable, but the menu groups them by tier. diff --git a/bin/workspace_instructions.py b/bin/workspace_instructions.py new file mode 100644 index 00000000..7a53f7f1 --- /dev/null +++ b/bin/workspace_instructions.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +"""Update only recognized workspace instruction sections, preserving local additions.""" +import argparse +import json +from pathlib import Path +import sys + +POLICY = Path(__file__).resolve().parents[1] / 'policy' + + +def render(text, sections, legacy): + """Refuse unexpected edits instead of overwriting a user's instructions.""" + replacements = [] + for heading, body in sections.items(): + lines = text.splitlines(keepends=True) + matches = [i for i, line in enumerate(lines) if line.rstrip() == heading] + if len(matches) != 1: + raise ValueError(f'expected one section: {heading}') + first = matches[0] + end = next((i for i in range(first + 1, len(lines)) + if lines[i].startswith('## ')), len(lines)) + current = ''.join(lines[first:end]).strip() + '\n' + if current not in (body.strip() + '\n', legacy[heading]): + raise ValueError(f'unrecognized local edits in {heading}; reconcile explicitly') + replacements.append((sum(map(len, lines[:first])), + sum(map(len, lines[:end])), body.rstrip() + '\n\n')) + for first, end, body in sorted(replacements, reverse=True): + text = text[:first] + body + text[end:] + return text.rstrip() + '\n' + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--root', type=Path, required=True) + parser.add_argument('--write', action='store_true', help='otherwise check only') + args = parser.parse_args(argv) + target = (args.root / 'AGENTS.md').resolve() # preserve a task-bundle symlink + try: + original = target.read_text() + updated = render(original, json.loads((POLICY / 'workspace_sections.json').read_text()), + json.loads((POLICY / 'workspace_sections_legacy.json').read_text())) + except (OSError, ValueError, KeyError) as exc: + print(f'workspace instructions: {exc}', file=sys.stderr) + return 2 + if original == updated: + print(f'OK: {target}') + return 0 + if not args.write: + print(f'DRIFT: {target}; run with --write after reviewing the change') + return 1 + target.write_text(updated) + print(f'updated: {target}') + return 0 + + +if __name__ == '__main__': + raise SystemExit(main()) diff --git a/docs/agent_reference.md b/docs/agent_reference.md new file mode 100644 index 00000000..6b2a94ec --- /dev/null +++ b/docs/agent_reference.md @@ -0,0 +1,147 @@ +# Agent architecture and command reference + +Read when designing agents or changing command wiring, not at session startup. + +## What this repo is + +PyAutoBrain is the **reasoning layer** of the PyAuto ecosystem as it grows into a +software organism. It figures out *how* work should be done and coordinates the +organs that do it. It hosts specialist **reasoning agents** — each a documented +role plus a deterministic entrypoint script — that read intent (from PyAutoMind +and the developer), reason about it, and drive the health/execution machinery at +the right points. + +PyAutoBrain owns **no state, no health checks, and no execution mechanics**. It +only *reasons* and *delegates*: it asks PyAutoHeart whether the organism is +healthy, decides whether and how to proceed, and tells PyAutoHands to execute +when it should. + +## The organism + +The organs, their boundaries, and the `Brain → Heart (gate) → Build (execute)` +call chain are defined **once** in [`ORGANISM.md`](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/ORGANISM.md) — this repo +hosts that canonical page; every other organ links to it. In one line: the +Mind decides *what*, the Brain (this repo) figures out *how*, the Heart gates, +the Hands build, Memory knows what the science says. + +## Brain agents consult one another (a society of agents) + +Brain agents are not limited to driving organs — they can **consult each other**. +The canonical example is the **Build Agent**, which does not query Heart directly: +it consults the **vitals faculty**, and only the vitals faculty talks to the Heart +organ. So the Build Agent's full chain is: + +``` +Mind → Build Agent → vitals faculty → Heart → GREEN/YELLOW/RED + → Build Agent → Build (execute) +``` + +The consult graph is a DAG (see [`ORGANISM.md`](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/ORGANISM.md)): conductors +consult faculties; faculties read their sensor organ; a conductor never +consults another conductor — if it wants one's opinion, that opinion should be +a faculty. The Build Agent is the reusable template for this pattern. + +How much human checkpointing a workflow run needs is defined once in +[`AUTONOMY.md`](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/AUTONOMY.md) — the autonomy contract mapping each Mind-prompt +`Autonomy:` level to behaviour at every checkpoint. + +## Specialist reasoning agents + +Agents live in **two tiers** under `agents/`, distinguished by one question — +*does it act, or only opine?* + +- **Conductors** (`agents/conductors//`) — front-door agents a human + **drives**. They *decide **and** act*, delegating execution to the organs. + They have side effects in the world (a plan driven into dev, a build, a + release). This is the small, curated set of things you invoke and converse + with. +- **Faculties** (`agents/faculties//`) — read-only reasoning capabilities + the conductors **consult**. They *only opine* — return a judgment and stop; + they never dispatch or mutate. They are *sinks* in the consult graph + (everything reaches into them; they reach out only to their sensor organ). Not + chat-first surfaces, though they stay runnable for a quick read. + +The rule of thumb: **keep the conductor set small and human-meaningful; let +faculties multiply behind them.** A side-effecting decider is a conductor; a +side-effect-free opinion is a faculty. + +Each agent is a directory with an `AGENTS.md` (what it reasons about + how to run +it) and a deterministic entrypoint script (`*.sh` / `*.py`) — the part CI and +humans invoke identically, so behaviour isn't re-derived from prose each time. + +New agents are added on **demonstrated need, never for symmetry**. Place by +tier: a side-effecting decider you drive → `agents/conductors//`; a +read-only opinion the conductors consult → `agents/faculties//`. Follow +the Build Agent's shape (a concise `AGENTS.md` opening with its `Tier:` line, a +deterministic entrypoint, and a capability audit of any organ it drives — the +Feature Agent's `MIND_TAXONOMY.md` is that audit for the PyAutoMind/PyAutoMemory +surface). Keep the conductor set small; prefer a faculty when the new thing +only reasons. + +**Scaling invariant.** The per-agent roster is not maintained here. Adding an +agent touches only `bin/pyauto-brain` (the registry) and the agent's own +directory (`agents///` with its `AGENTS.md` + entrypoint). The verb +tables below are **generated** from that registry by +`bin/install.sh --write-agents-surface` — never hand-edit this file's roster, +and read each agent's own `AGENTS.md` for its full role. + + +## The command surface (Brain implicit) + +The verb table in [AGENTS.md](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/AGENTS.md) is the machinery; humans drive it through short commands +(`/intake`, `/feature`, …) in Claude Code, or discoverable skills in Claude and +Codex. The Brain stays **implicit** — you type a verb, or plain natural language +via `/route`, and it routes to the right agent; normal usage never says +"PyAutoBrain". A few commands are compositions rather than single agents: +`/docs` and `/research` route through the dev-flow with their PyAutoMind +work-type fixed (no dedicated conductor — added only on demonstrated need, never +for symmetry); `/prm` composes the +end-of-task close-out (CI green → merge → issue closed → Mind `active/` → +`complete/` → dashboard reconciled and regenerated → worktree and local branches +removed); `/brain +` is the raw passthrough. Every command routes **through** the Brain; +none replaces it. + +The morning routine is not a command at all: the **Brain board** +(`board/_board.py`, published to the Brain's GitHub Pages URL each morning by +`brain_board.yml`) carries what `/wake_up` used to assemble — overnight runs, +readiness, community, resume, upkeep — as one-tap 📋 payloads, and +`bin/morning.sh` is the local sync/clean leg you run in a terminal. +`/wake_up` remains only as the fallback door when the board is unreachable. + +The command bodies live in `skills//.md`; thin `SKILL.md` wrappers +make the same canonical workflows discoverable to skill-aware harnesses. +`bin/install.sh` installs both surfaces without duplicating their bodies. Shared +architecture prose is in [`skills/COMMANDS.md`](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/skills/COMMANDS.md); the +work-type taxonomy the router uses is `PyAutoMind/ROUTING.md`. + +## Chat register: concise by default + +The default register for **chat replies** is concise — every harness and every +session (Claude Code CLI, web, mobile; Codex; Cursor). A reply is the smallest +thing that answers the question and says what changed. It is not a report on the +work. + +- **Answer first.** Lead with the answer, the verdict, or what you did. No + preamble, no restatement of the request, no summary of the summary. +- **A few lines is the default length.** One line is a good answer. Prose + paragraphs, file-by-file inventories and "what I did / why / next steps" + scaffolding are opt-in, not the baseline. +- **Don't narrate the work.** Skip the tool-by-tool commentary, the list of + files read, and any recap of a diff the human can read on the branch or PR. +- **Link, don't paste.** Point at the file, the issue, the PR, the prompt under + `PyAutoMind/draft/`; quote only the lines being discussed. + +Four things are never compressed: a **plan awaiting approval**, a **decision +surface** a human must judge, a **failure or blocker** (say exactly what broke +and where), and anything the human **asked to have explained**. Brevity is not a +licence to drop the detail a decision needs. + +The escape hatch is a word — "expand", "in full", "explain" — and it applies to +that reply, not the session; the register comes back on the next turn. + +Agent output is not chat and keeps its defined shape: a `*Decision`, a +`ReviewSurface`, a vitals verdict, the board digest are structured artefacts +this register does not trim. It governs the prose around them. On Claude Code +the same default can also be pinned per-tool with an output style, but the +register above is the portable one — it travels with the repo to every harness. diff --git a/docs/codex_usage.md b/docs/codex_usage.md index bdc7fe53..a87feb21 100644 --- a/docs/codex_usage.md +++ b/docs/codex_usage.md @@ -53,3 +53,9 @@ Compare medians only across similar task types and report unknown sessions. Treat the current Astra Medium configuration as the baseline; do not change local model configuration merely to manufacture a comparison. Do not claim savings until both usage and outcome/correction evidence support it. + +## Static context budgets + +Use [context_efficiency.md](context_efficiency.md) for the September follow-up, +Mind’s token-load checker and post-merge root activation. Static byte/line +reductions are not measured task-token savings. diff --git a/docs/context_efficiency.md b/docs/context_efficiency.md new file mode 100644 index 00000000..821fb55a --- /dev/null +++ b/docs/context_efficiency.md @@ -0,0 +1,60 @@ +# Context efficiency after grouped workspace migration + +The September 19, 2026 follow-up keeps all approval, Heart, review and release +requirements. It reduces repeated reads, not the evidence needed to decide. + +- Root, Brain and Mind AGENTS: 43,365 bytes before; 25,731 bytes after + the root update, a 40.7% reduction in these maintained instruction surfaces. +- Brain AGENTS: 18,471 → 9,654 bytes; Mind: 12,507 → 5,070 bytes. +- PRM body: 349 → 169 lines. Its MCP lane, library freeze details and post-merge + close-out are conditional reads. They remain required when their trigger applies. +- The new context guide and wrappers are included in procedure accounting: + approximately 377 mandatory lines for start-dev and 370 for PRM, including + shared context/workflow pages. Shared pages are reused within a session. + +These are static byte/line measurements, not tokenizer results or measured +runtime/billing savings. The usage study had a 98.6% median cached-input rate +across 14 Astra-containing parent sessions; workers and differing scopes prevent +an exact before/after task-cost claim. Use [codex_usage.md](codex_usage.md) for +subsequent matched-task comparisons, including outcomes and correction loops. + +## Check maintained budgets + +From the resolved Mind checkout (set `PYAUTO_ROOT` to the workspace being measured): + +```bash +python3 scripts/token_load.py report --root "$PYAUTO_ROOT" +python3 scripts/token_load.py check --root "$PYAUTO_ROOT" +``` + +The report lists core and conditional files separately, includes entry wrappers, +counts shared workflow/context pages, and reports their union without duplicates. +Missing required files fail the check. Byte/4 estimates are explicitly approximate. + +## Activate root instructions after both PRs merge + +Repo instructions and linked skills take effect when the installed main checkouts +advance. The untracked workspace root needs this explicit, reviewable local step. +From the updated Brain checkout: + +```bash +source bin/_pyauto_root.sh +source bin/_repo_paths.sh +python3 bin/workspace_instructions.py --root "$PYAUTO_ROOT" # check +python3 bin/workspace_instructions.py --root "$PYAUTO_ROOT" --write +bash bin/install.sh --write-workspace-policy +``` + +Machine-specific HPC instructions remain local and untouched. +The section updater changes only recognized old/new sections; unexpected local +edits fail closed. It preserves custom top-level sections, generated routing, +safety rules and symlinks. Do not overwrite local additions to resolve a refusal. +Refresh root routing and the Brain owner map using Mind's `repos_sync.py` after +reviewing its write scope (its `--only` flag scopes checks, not generation). +For a two-surface refresh, use that module's `routing_table`/`owner_map` and +`write_block` APIs rather than writing every other repository's generated files. +The task root preview is the review artifact; installation is not a merge grant. + +[CONTEXT.md](https://github.com/PyAutoLabs/PyAutoBrain/blob/main/skills/CONTEXT.md) defines bounded results and completed-phase +handoffs. Continue authorized work; fresh sessions are a human choice at natural +boundaries, not a reason for agents to stop early. diff --git a/docs/index.md b/docs/index.md index 9ddbd3cd..d73db947 100644 --- a/docs/index.md +++ b/docs/index.md @@ -77,6 +77,8 @@ example agent_failure_modes codex_usage +agent_reference +context_efficiency agent_harness_smoke workspace_layout ``` diff --git a/policy/workspace_model_delegation.md b/policy/workspace_model_delegation.md index 4674aaf9..bb983111 100644 --- a/policy/workspace_model_delegation.md +++ b/policy/workspace_model_delegation.md @@ -6,5 +6,5 @@ needing separate context, or independent review. Duration alone is not a reason to spawn. Brain roles are not automatic LLM spawns. State the session model before the first delegation decision. Full policy: - `PyAutoBrain/skills/MODEL_DELEGATION.md`. + `skills/MODEL_DELEGATION.md` in the resolved Brain checkout. diff --git a/policy/workspace_model_delegation_pointer.md b/policy/workspace_model_delegation_pointer.md index 14edfe59..3a41af4e 100644 --- a/policy/workspace_model_delegation_pointer.md +++ b/policy/workspace_model_delegation_pointer.md @@ -1,5 +1,4 @@ -- **Model delegation** (Anthropic execution tier; OpenAI direct-by-default; - bounded workers; tutorial and Cortex behavior) - → `PyAutoBrain/skills/MODEL_DELEGATION.md`. +- **Model delegation** (provider rules, bounded workers, teaching and Cortex) + → `skills/MODEL_DELEGATION.md` in the resolved Brain checkout. diff --git a/policy/workspace_sections.json b/policy/workspace_sections.json new file mode 100644 index 00000000..01bde0c6 --- /dev/null +++ b/policy/workspace_sections.json @@ -0,0 +1,5 @@ +{ + "## Context load discipline (read this first)": "## Context load discipline (read this first)\n\nFor unrouted work, start with **PyAutoMind + PyAutoBrain only**. Read another\nrepo's instructions/source only when the user names its domain, a task/issue\npoints to it, or Brain routes there. Never load every repo to orient.\nAttach only Mind + Brain for multi-repo web/chat entry; add other repos on demand.\nReuse unchanged instructions already loaded. Read the invoked skill's current\nstep and applicable environment, not every reference. Scope searches and return\nsummaries/failure excerpts; retain full logs outside chat. See Brain's\n`skills/CONTEXT.md` for path resolution, bounded output and phase handoffs.\n", + "## Development workflow (default routing)": "## Development workflow (default routing)\n\nImplementation, fixes, features, refactors, migrations, docs, tests, shipping and\nPR requests use **start_dev** automatically. With no prompt, create one in the\nresolved Mind checkout's `draft///`, copying the request\nverbatim. Explicit \"--auto\", \"autonomously\" or \"hands-off\" invokes Brain's\n`AUTONOMY.md`; it is never ambient.\n\n1. start_dev classifies, plans and surveys affected branches/claims.\n2. Approved library work: start_library \u2192 edit \u2192 ship_library. Workspace work:\n start_workspace \u2192 edit \u2192 ship_workspace. Both: library first.\n3. Edit only after approval and worktree setup. A plan already approved in this\n session remains approved; confirm only genuinely new scope or conflicts.\n\nQuestions, reviews, status, search and diagnostics need no start_dev. Honor\nexplicit workflow opt-outs after confirming safety. Instruction/skill wiring may\nbe changed directly; still report repo root and branch first.\n\nCanonical skills live in the owning checkout: Brain `skills/{start_dev,\nstart_library,start_workspace,ship_library,ship_workspace}`, Heart\n`skills/{smoke_test,review_release,verify_install}`, Hands `skills/pre_build`,\nand Mind `skills/create_issue`. Read only the invoked skill.\n", + "## On-demand pointers (do NOT inline these into context by default)": "## On-demand pointers (do NOT inline these into context by default)\n\n\n- **Model delegation** (provider rules, bounded workers, teaching and Cortex)\n \u2192 `skills/MODEL_DELEGATION.md` in the resolved Brain checkout.\n\n- **Repository paths:** the table names canonical main checkouts. Flat task\n bundles/remote clones differ; resolve via Brain's `agents/_repo_paths.py`,\n not guessed parent/sibling paths. See Brain `skills/CONTEXT.md`.\n- **Post-merge cleanup:** the invoked ship skill and prm close-out procedure.\n- **Science background:** relevant pages only under `organs/PyAutoMemory/wiki/`\n (`lensing`, `smbh`, `cti`, `methods`, `galaxies`).\n- **Lensing plan gate:** before finalizing lensing science/API/tutorial plans,\n read `lens/autolens_assistant/AGENTS.md`, `wiki/project/profile.md` if present,\n then only relevant `skills/`, `wiki/core/` or `wiki/literature/` pages.\n" +} diff --git a/policy/workspace_sections_legacy.json b/policy/workspace_sections_legacy.json new file mode 100644 index 00000000..f9f9bc1b --- /dev/null +++ b/policy/workspace_sections_legacy.json @@ -0,0 +1,5 @@ +{ + "## Context load discipline (read this first)": "## Context load discipline (read this first)\n\nThis workspace contains ~25 repositories. **Do not inspect or load all of them by\ndefault.** Loading every repo's `AGENTS.md` to \"orient\" is the main cause of\nrunaway context/token use, and it is unnecessary \u2014 route from the table below.\n\n- For a **generic or unrouted prompt**, only two repos are in scope:\n **PyAutoMind** (what should be done) and **PyAutoBrain** (how it should be done).\n Do not open any other repo's docs or source.\n- Read a specific repo's `AGENTS.md` or source **only when** one of these is true:\n 1. the user **names** that repo or its domain,\n 2. a **PyAutoMind task** or **GitHub issue** points to it,\n 3. **PyAutoBrain** routes the work to it.\n- Per-repo `AGENTS.md` files are **on-demand references**, not startup reading.\n Read one repo's doc when you begin work in that repo \u2014 never fan out across\n all of them.\n- **Multi-repo web/chat sessions:** attach only **PyAutoBrain + PyAutoMind** as\n the entry point and pull other repos in per task. Attaching all repos forces\n every repo's canonical doc into context before the first message is even read.\n\nAs work moves through a PyAutoBrain agent, this routing becomes automatic; until\nthen, apply the discipline manually.\n", + "## Development workflow (default routing)": "## Development workflow (default routing)\n\nTreat any request to implement, fix, add, change, refactor, migrate, optimize,\ndocument, test, ship, or open a PR \u2014 for any library, workspace, tutorial,\nbuild/release, or project-doc \u2014 as a **development task**, even if the user does\nnot say `start_dev` or name a skill.\n\n1. If given a `organs/PyAutoMind///.md` prompt path, run\n `start_dev` on it. Otherwise create a concise PyAutoMind prompt (original\n request verbatim) first, then `start_dev`. If the user asks for `--auto`\n (any phrasing \u2014 \"run this auto\", \"autonomously\", \"hands-off\"), run\n `start_dev --auto` per `organs/PyAutoBrain/AUTONOMY.md`.\n2. `start_dev` classifies the work and surveys affected branches:\n - **library** \u2192 `start_library` \u2192 source edits \u2192 `ship_library`\n - **workspace** \u2192 `start_workspace` \u2192 workspace edits \u2192 `ship_workspace`\n - **both** \u2192 library first, workspace follow-up once API impact is known.\n3. Do not edit before the plan is approved and the branch/worktree survey\n (`start_dev` step 4) has run (under `--auto`, plan approval follows the\n contract exception in the safety rules above; the survey always runs).\n\nExceptions: pure questions, reviews, status, search, diagnostics need no\n`start_dev`; explicit \"skip the workflow / one-off local edit\" is honored after\nconfirming safety; changes to the workflow instructions or skill wiring itself\nmay be made directly, but still report repo root + branch first.\n\nCanonical skill bodies (do not duplicate \u2014 edit the shared file):\n`organs/PyAutoBrain/skills/{start_dev,start_library,start_workspace,ship_library,ship_workspace}`,\n`organs/PyAutoHeart/skills/{smoke_test,review_release,verify_install}`,\n`PyAutoBuild/skills/pre_build`, and `organs/PyAutoMind/skills/create_issue`.\n", + "## On-demand pointers (do NOT inline these into context by default)": "## On-demand pointers (do NOT inline these into context by default)\n\n\n- **Model delegation** (Anthropic execution tier; OpenAI direct-by-default;\n bounded workers; tutorial and Cortex behavior)\n \u2192 `organs/PyAutoBrain/skills/MODEL_DELEGATION.md`.\n\n- **Post-merge cleanup** (worktree removal, branch deletion, registry moves) \u2192\n the `ship_library` / `ship_workspace` skills.\n- **Scientific context** (lensing, SMBH, CTI/Euclid, inference methods, galaxy\n evolution \u2014 concepts, entities, ~600-paper bibliographies) \u2192 **organs/PyAutoMemory/**\n sub-wikis under `wiki/`: `lensing/`, `smbh/`, `cti/`, `methods/`,\n `galaxies/`. Read the relevant sub-wiki when a change or science tutorial\n needs domain background; do not bulk-load it.\n- **Lensing assistant** \u2014 before finalising a plan for PyAutoLens / lensing\n science / substructure / SLaM / source reconstruction / mass modelling / lens\n tutorial prose, consult `autolens_assistant/`: read `autolens_assistant/AGENTS.md`,\n then `wiki/project/profile.md` if present, then only the relevant\n `skills/*.md` / `wiki/core/` / `wiki/literature/` pages. Do not bulk-load it.\n" +} diff --git a/skills/CONTEXT.md b/skills/CONTEXT.md new file mode 100644 index 00000000..08c56d59 --- /dev/null +++ b/skills/CONTEXT.md @@ -0,0 +1,68 @@ +# Context and output discipline + +Read this once for development or review. It changes how evidence is loaded, +not any approval, test, independent-review, Heart or release requirement. + +## Resolve locations once + +Repository names in prose (for example `PyAutoMind/active.md`) identify a +repository-relative file, not a fixed workspace-root path. Main checkouts may +be grouped under `organs/`, `lens/`, etc.; task bundles and remote clones may +be flat. Use the manifest-backed resolver already in Brain. From the **Brain +checkout** (locate it using the workspace routing map): + +```bash +source bin/_pyauto_root.sh +source bin/_repo_paths.sh +export PYAUTO_BRAIN="$(pyauto_repo_path PyAutoBrain "$PYAUTO_ROOT")" +export PYAUTO_MIND="$(pyauto_repo_path PyAutoMind "$PYAUTO_ROOT")" +``` + +Keep these paths for the current checkout. Resolve other repositories only when +needed, with `pyauto_repo_path "$PYAUTO_ROOT"`; use `--required` with +`agents/_repo_paths.py path` when existence is mandatory. Re-resolve after +changing worktree/root or moving checkouts. Do not reuse main paths inside a +task bundle. Run Mind's `scripts/lifecycle.py` from the resolved Mind checkout. +On a GitHub-only surface use repository identity and API paths, not shell setup. + +## Read the applicable procedure + +- Load the workspace rules, target repo instructions and invoked skill once. + Reuse them while unchanged. Refresh after an instruction edit, branch/root + change or compaction that lost a required rule; do not assume missing context. +- Reference files are indexes: locate headings, then read the current section. + Do not concatenate every reference at startup. Select the local or remote + lane once. Load linked-library instructions only for a linked task, autonomy + details only when applicable, and post-merge close-out only after merging. +- Never replace an independent review with the author's summary. Give the + reviewer a bounded scope and direct access to the diff and supporting evidence. + +## Bound tool results + +- Search paths first (`rg --files`), then scoped text (`rg -n`), then the relevant + lines. Do not dump every sibling's instructions or entire registries. +- For routine status, use diff statistics, selected JSON fields, pass/fail + counts and failure excerpts. Default to roughly 1–2k output tokens per call; + raise the limit deliberately when the decision needs more evidence. +- Save full test/build logs in the task's ignored scratch directory. Return + exit status, counts and the relevant failure tail, with a log path. Preserve + the command's exit code; a successful `tail` must not mask a failed test. +- If output is truncated, narrow the query. Never assume the missing part was + clean. Keep exact gate reasons and complete review findings available. +- Batch independent reads. Do not repeat an unchanged successful check without + changed inputs or a gate requiring it. Reuse a worker for coherent fixes; + communicate milestones or actionable findings, not repeated status requests. + +## Completed-phase handoff + +At a completed phase, refresh the existing issue/Mind task record with: +objective and remaining scope; accepted decisions and authorizations; worktree, +branch and commit; changed files; validation results with log paths; open risks +or review findings; and the next concrete action. Keep this to a short section +(about 10–20 lines), linking evidence instead of copying logs or chat history. + +Continue already-authorized work in the current turn. Do not stop solely to +force a fresh chat, start a replacement session automatically, or treat a +handoff as new approval. When the user resumes in a fresh session, load that +record and verify the current branch/claims before continuing. A handoff never +carries expired merge authority, clears a gate, or replaces independent review. diff --git a/skills/WORKFLOW.md b/skills/WORKFLOW.md index 46e3bba7..b6a45163 100644 --- a/skills/WORKFLOW.md +++ b/skills/WORKFLOW.md @@ -4,6 +4,9 @@ The `start_*` and `ship_*` skills are entry points, not independent reasoning systems. Mind owns task state, Brain plans and coordinates, Memory supplies read-only context, Heart gates shipping, and Hands handles releases only. +Read [CONTEXT.md](CONTEXT.md) once for bounded reads/output, phase handoffs and +grouped/flat path resolution. Reuse unchanged instructions already loaded. + ## Call chains ```text @@ -25,7 +28,7 @@ bin/pyauto-brain vitals bin/pyauto-brain build --dry-run ``` -If Brain is unavailable, emulate the requested decision from `PyAutoBrain/AGENTS.md` +If Brain is unavailable, emulate the requested decision from its `AGENTS.md` and this file, and say that it was emulated. ## Model delegation @@ -84,7 +87,7 @@ review, and Heart form the ship gate. Merge is always a current human action. ## Task state and worktrees -Mind paths are workspace-root-relative: `PyAutoMind/active.md`, `planned.md`, +Mind paths are relative to its resolved checkout: `active.md`, `planned.md`, and prompt lifecycle `draft/ → active/ → complete/YYYY/MM/`. Use Mind's lifecycle and prompt-sync scripts; do not hand-roll state transitions. @@ -106,5 +109,5 @@ All repos live at `PyAutoLabs/` on GitHub, except: `Jammy2211/eu **Library repos:** PyAutoFit, PyAutoArray, PyAutoGalaxy, PyAutoLens, PyAutoReduce, PyAutoCTI. **Workspace repos:** autofit_workspace, autogalaxy_workspace, autolens_workspace, autocti_workspace, autoreduce_workspace, autofit_workspace_test, autogalaxy_workspace_test, autolens_workspace_test, autocti_workspace_test, HowToFit, HowToGalaxy, HowToLens, euclid_strong_lens_modeling_pipeline. -Generated from `PyAutoMind/repos.yaml`; edit there, then run `python3 PyAutoMind/scripts/repos_sync.py --write`. +Generated from `PyAutoMind/repos.yaml`; from the resolved Mind checkout, edit `repos.yaml`, then run `python3 scripts/repos_sync.py --write`. diff --git a/skills/docs/docs.md b/skills/docs/docs.md index b5e0cf71..f72d6434 100644 --- a/skills/docs/docs.md +++ b/skills/docs/docs.md @@ -11,7 +11,7 @@ Shared routing context: `PyAutoBrain/skills/COMMANDS.md`. Treat the request as PyAutoMind work-type **`docs/`** — documentation, examples, notebooks, or tutorial prose. If no prompt path exists, create one under -`PyAutoMind/docs//.md` (original request verbatim), then run +`PyAutoMind/draft/docs//.md` (original request verbatim), then run **`/start_dev`** on it. `start_dev` routes through the Brain, and the tutorial The judgment/execution tier split in `../WORKFLOW.md` applies. Taxonomy: `PyAutoMind/ROUTING.md`. diff --git a/skills/prm/SKILL.md b/skills/prm/SKILL.md index 2c578e68..c23a69aa 100644 --- a/skills/prm/SKILL.md +++ b/skills/prm/SKILL.md @@ -1,6 +1,6 @@ --- name: prm -description: The last thing you type for a task — "PR, CI green, then merge", then the full close-out. Judges a feature PR's checks — every workflow run and every matrix leg — and merges only when all are green (on mobile or web it judges once, reports and stops; the human re-runs it — no subscription, no timer; library-first gate honoured), closes the issue, moves the PyAutoMind prompt active/ → complete/, reconciles and regenerates the Mind dashboard, removes the task worktree and its local branches. Use when the user says merge this PR once CI is green, close this task out, or types /prm. Runs on any GitHub surface — gh on a local CLI, the GitHub MCP tools in a mobile or web session, Codex. +description: Judge every CI run and matrix leg, merge human-authorized PRs when green, then close the issue and Mind task and clean the worktree. Use for /prm or merge-and-close requests; preserve library-first and data guards. --- # /prm — PR, CI green, then merge, then close the task out @@ -14,3 +14,7 @@ render from `/intake`. Typing `/prm` authorizes the **whole** close-out, so it runs to the end without asking again — but still refuses on red, pending, conflicting, an unmerged upstream library PR or sibling branch, and asks once before deleting a worktree holding irreplaceable data products. + +Read only the applicable step/environment from linked references, not all files. +Reuse unchanged instructions already loaded; follow [CONTEXT.md](../CONTEXT.md) +for bounded output and repository paths. diff --git a/skills/prm/closeout.md b/skills/prm/closeout.md new file mode 100644 index 00000000..57dfd5b2 --- /dev/null +++ b/skills/prm/closeout.md @@ -0,0 +1,155 @@ +# Post-merge close-out + +On MCP use [mcp.md](mcp.md); consult [GITHUB_ACCESS.md](../GITHUB_ACCESS.md) +only for an operation missing from that lane. + +Read this procedure only after the merge gates in [prm.md](prm.md) pass. +Read [reference.md](reference.md) by the corresponding section, not in full. +All Mind paths below are relative to the resolved Mind checkout. + +## 5. Close the task out + +Typing `/prm` authorized all of this; the only questions are the guards in step +6. Order is forced by the tooling, so do not reorder: + +1. **Prove every branch merged, per repo** — a `complete/` record is a write-up, + not a merge receipt, and a task may have shipped in waves. Ask git, per repo + the task claims, never the record. Any repo with unmerged commits and no open + PR **stops the close-out**: a half-merged task must not be recorded complete. +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 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 + `draft///` prompt pointing back at the record. Recording a + prompt whole on a partial merge is what leaves half-done work on the dashboard + as pickable backlog. + + **Carry `pending-release:` into the record.** A library PR merged here is not + a released library, and the `active.md` row that held that fact is about to + be pruned. Copy every uncleared `- pending-release: @` line from + the row into the completion body, so the obligation outlives the row and the + dashboard's **Pending release** section keeps showing it. `/prm` never + clears the key — only `/review_release` does, on a release that actually + published (`PyAutoMind/REFERENCE.md` → "The pending-release chain"). + + **3b. Shadow row — tier-`notify` only.** The tier-`notify` auto-merge + decision is pre-registered over **40 candidates**, and this close-out is + where the window is fed. It used to hang off a batch review slot, which + runs only when a batch is launched; close-out happens on every shipped + task. Do it only after sub-step 1 proved every branch `MERGED` — the row + records what the human *did* with the PR, and before the merge there is + nothing to record. + + 1. **Tier.** The prompt's declared `Consequence:` header wins; with no + header, `bin/pyauto-brain sizing `. Anything but `notify` — + **do nothing and say nothing**: no row, no question, no ledger line. + 2. **Gate cell.** Copy it from the task's ship calibration row in + `PyAutoMind/autonomy_log.md` — `ship_library` / `ship_workspace` wrote + it at PR-open. No such row (a task that never went through ship)? Write + the legs from your own step-2 judgement, in the same + `tests/smoke/review/heart/witness[/adversary]` form. Never invent a + greener gate than the one that ran. + 3. **Stage.** `2` if an independent-model adversary leg ran on this task, + else `1`. Stage 1 and stage 2 are never pooled, so this is not a + judgement call: the leg either ran or it did not. + 4. **The one question.** Ask the human exactly this, and ask nothing else: + + > Merged unchanged, or did you change something substantive first? + > (substantive = a change you would have minded finding already merged: + > a changed default, a user-visible error message, a removed or weakened + > test, a renamed public thing, a wrong docs claim) + + → `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** — 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". + + Protocol, power calculation and the **pre-registered decision rule** live in + the tier-`notify` protocol prompt, folded under `## Original prompt` in + `PyAutoMind/complete/2026/09/prm-shadow-row-notify-tier.md` — read it + before interpreting the table. +4. **Mind: leave the page true** — the close-out is finished when `dashboard.md` + stops offering this work, not when the claim is released. + `dashboard_refresh.yml` heals a stale *render*, never a stale *prompt*, so + this leg belongs to `/prm` and to nothing else. + + 1. **Sweep** — grep the slug and the prompt filename across `draft/`, + `active/`, `epics.md` and the registry files; repoint or remove every hit + the merge falsified (an unblocked `blocked-by:`, a finished epic phase, a + `superseded-by:` chain that now ends in a record). + 2. **Reconcile** — `pyauto-brain intake reconcile draft//` + over the shipped prompt's folder plus any the merged diff lands in; + folder-scoped, never whole-backlog. **Proof retires, resemblance reports**: + a sibling this merge provably covers gets its own record and `git rm` under + the same `/prm` authorization; one that merely *looks* alike gets a ledger + line and the `/intake reconcile` door — never a second question (step 6 + owns the only one). + 3. **Regenerate — always**, whatever 1 and 2 found; moving a prompt into + `complete/` changes the page by itself, so this leg has no "nothing + changed" exit, only a `--check` that says the render is current: + + ```bash + pyauto-brain intake --apply dashboard # writes dashboard.md + dashboard.html + pyauto-brain intake dashboard --check # must print "…are current" + ``` + + Never hand-edit either page. Commit the render **with** the record, then + `lifecycle.py check` and push Mind. `git show --stat HEAD` must name both + dashboard files beside the record, or leg 3 did not happen. + + **Push the branch you are on — never force `main`.** On a laptop that branch + *is* `main`. On a branch-scoped surface (the phone, claude.ai/code, any + `claude/**` or `codex/**` flow) it is the session's branch, and pushing it is the whole + job: a close-out diff is ledger by construction, so + `mind_ledger_merge.yml` merges it into `main` and can delete the branch after its checks pass — no PR, and no "merge that branch too" left for the human. Say in + the ledger that the Mind branch was pushed and will land itself. Two things + change that: the close-out also touched `scripts/`, `.github/`, `skills/` or + another code path (then the branch waits for a human — say so plainly), or + `lifecycle.py check` fails (then it was never going to merge; fix the drift). + `python3 scripts/ledger_merge.py classify --base origin/main` in the Mind + checkout tells you which of the three you are in. +5. **Worktree** — `worktree_remove `, never `rm -rf`. It refuses on a dirty + repo and on a claim still registered in `active.md` — which is exactly why + step 3 comes first. +6. **Local branches only** — delete a local `feature/` left in the + canonical checkout, never one whose merge you did not prove in sub-step 1. + **The remote branch is not yours to delete**: GitHub removes a merged head + itself, and `branch_sweep*.yml` / `/repo_cleanup` collect what escapes. + Nothing to do, and no ledger line — not "deferred", not "blocked". +7. **Report the ledger** — PRs merged, issue closed, record path, `active.md` + released, **dashboard regenerated** (plus any sibling retired, any suspect + left standing with its `/intake reconcile` prefix), worktree removed, and + anything skipped. That dashboard line is not prose: if you cannot write it, + leg 4.3 did not run — go back and run it. + +**On `mcp`:** 1 and 2 run as usual; 3 works if PyAutoMind is checked out, else +the record is pending. Leg 4 needs **both** checkouts (state is Mind's, renderer +is Brain's): with only Mind, sweep and reconcile and leave the render to +`dashboard_refresh.yml`; with neither, call the leg pending rather than implying +the page is true. 5 and 6 are local-only — name 5 outstanding, say nothing of 6. diff --git a/skills/prm/freeze.md b/skills/prm/freeze.md new file mode 100644 index 00000000..743e0ba6 --- /dev/null +++ b/skills/prm/freeze.md @@ -0,0 +1,35 @@ +# Library merge freeze gate + +Read before merging any library PR; organs/workspaces skip this page. +All other [merge gates](prm.md) still apply. + +1. **The Heart freeze window — library PRs only.** A release validation is a + window in which the library `main`s must not move: a merge landing inside it + invalidates the evidence and restales the rehearsal (~75 minutes, measured + 2026-08-29). Heart's flag says whether one is open: + + ```bash + pyauto-heart freeze --show # exit 3 = frozen; 0 = clear or expired + ``` + + Active **and** a target PR is in a **library** repo (the `category: library` + entries of `PyAutoMind/repos.yaml`) → stop, report the `FROZEN: …` line + verbatim, and say when it expires. Organ and workspace repos are not gated; + a workspace PR whose library half is held waits on the library-first gate + below anyway. Where Heart is not installed (mobile, web, CI) there is + nothing to read — say so in one line; an absent flag is not a freeze. + + **`--thaw ""` is the only way past**, and it is loggable by + construction: merge, then append one row to `PyAutoMind/autonomy_log.md` + under a `## Freeze overrides` heading (create the section, with this header, + on first use) — + + ``` + | date | task / PR | freeze reason | until | thawed by | why | + ``` + + — in the same Mind push the close-out already makes (step 5.4). The override + exists because a freeze is advice about evidence, not a protected branch, + and an unloggable override is one people route around instead of recording. + Never thaw silently, and never thaw to get past a red check: this gate is + about *when*, and step 2 is about *whether*. diff --git a/skills/prm/mcp.md b/skills/prm/mcp.md new file mode 100644 index 00000000..744a21c4 --- /dev/null +++ b/skills/prm/mcp.md @@ -0,0 +1,26 @@ +# MCP close-out calls + +Consult [GITHUB_ACCESS.md](../GITHUB_ACCESS.md) only for an operation missing +from this lane. + +Read only on the MCP surface; follow all gates in [prm.md](prm.md). + +### The `mcp` lane, step by step + +Every GitHub call a close-out makes, so a mobile run reads this page and the +mapping page only if something here is missing. Names take the +`mcp__github__` prefix; `ToolSearch` fetches a schema that is not loaded. + +| Step | Call | +|---|---| +| 1 resolve | `list_pull_requests` (state `open`), or `pull_request_read` `get` for a known number. Mind's `active.md` via `get_file_contents` | +| 2 judge CI | `pull_request_read` `get_check_runs` — every check on the head commit, in one call. Then `pull_request_read` `get` for `mergeable` / `merge_state_status` | +| 2 by workflow | `actions_list` `list_workflow_runs` **has no `head_sha` filter** (`workflow_runs_filter` is actor/branch/event/status only): filter by `branch`, then match `head_sha` yourself, or you will judge a stale run. Legs: `actions_list` `list_workflow_jobs`, `resource_id` = run id | +| 3 stop | **No call.** On this surface step 3 is judge-once-then-stop: no `subscribe_pr_activity`, no `send_later`. Report where each PR stands and end the turn; the human re-runs `/prm` when CI is green | +| 3 red | `get_job_logs` with `run_id`, `failed_only: true`, `return_content: true` — **before** anything else, the blob is purged | +| 4 merge | `merge_pull_request` (`merge_method: "merge"`), then `pull_request_read` `get` to confirm `MERGED`; `unsubscribe_pr_activity` only to clear a stale subscription an older run left | +| 5.2 issue | `add_issue_comment`, then `issue_write` `update` with `state: "closed"` and `state_reason: "completed"` — an unset reason is what leaves an issue reading "closed as not planned" | +| 5.1 proof | git, not GitHub — and `--is-ancestor` needs an unshallowed clone (`reference.md` §1) | + +Steps 5.3-5.7 touch no GitHub API at all; what they need is a checkout, and the +note at the foot of step 5 says what to do without one. diff --git a/skills/prm/prm.md b/skills/prm/prm.md index 49cc8196..763f009e 100644 --- a/skills/prm/prm.md +++ b/skills/prm/prm.md @@ -5,7 +5,9 @@ moment they are genuinely green, then close the task out — issue closed, promp moved `active/` → `complete/`, `dashboard.md` reconciled and regenerated, worktree and local branches removed — and hand back a ledger. -Each step below has a matching section in [`reference.md`](reference.md) carrying +Load this procedure once. Skip the MCP lane on local CLI; on MCP skip local +command recipes. Read the close-out only after merging. Reuse unchanged +references already loaded. Each step below has a matching section in [`reference.md`](reference.md) carrying its commands, failure signatures and reasoning (the close-out's sub-steps are its numbered §1-7); read it when you run the step. Routing: `PyAutoBrain/skills/COMMANDS.md`. `/prm` sequences owners it never @@ -44,25 +46,7 @@ command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1 \ `/prm` **deletes no remote branch on any surface** (step 5.6), so nothing here needs the second probe that step used to carry. -### The `mcp` lane, step by step - -Every GitHub call a close-out makes, so a mobile run reads this page and the -mapping page only if something here is missing. Names take the -`mcp__github__` prefix; `ToolSearch` fetches a schema that is not loaded. - -| Step | Call | -|---|---| -| 1 resolve | `list_pull_requests` (state `open`), or `pull_request_read` `get` for a known number. Mind's `active.md` via `get_file_contents` | -| 2 judge CI | `pull_request_read` `get_check_runs` — every check on the head commit, in one call. Then `pull_request_read` `get` for `mergeable` / `merge_state_status` | -| 2 by workflow | `actions_list` `list_workflow_runs` **has no `head_sha` filter** (`workflow_runs_filter` is actor/branch/event/status only): filter by `branch`, then match `head_sha` yourself, or you will judge a stale run. Legs: `actions_list` `list_workflow_jobs`, `resource_id` = run id | -| 3 stop | **No call.** On this surface step 3 is judge-once-then-stop: no `subscribe_pr_activity`, no `send_later`. Report where each PR stands and end the turn; the human re-runs `/prm` when CI is green | -| 3 red | `get_job_logs` with `run_id`, `failed_only: true`, `return_content: true` — **before** anything else, the blob is purged | -| 4 merge | `merge_pull_request` (`merge_method: "merge"`), then `pull_request_read` `get` to confirm `MERGED`; `unsubscribe_pr_activity` only to clear a stale subscription an older run left | -| 5.2 issue | `add_issue_comment`, then `issue_write` `update` with `state: "closed"` and `state_reason: "completed"` — an unset reason is what leaves an issue reading "closed as not planned" | -| 5.1 proof | git, not GitHub — and `--is-ancestor` needs an unshallowed clone (`reference.md` §1) | - -Steps 5.3-5.7 touch no GitHub API at all; what they need is a checkout, and the -note at the foot of step 5 says what to do without one. +On MCP, read [mcp.md](mcp.md) for the exact calls; do not load local recipes. ## 1. Resolve the target PR(s) @@ -124,36 +108,9 @@ before checks are green, it expires: arm no waiter or auto-merge, stop, and require the human to invoke `/prm` again. This permission never reaches a release or release rehearsal. -1. **The Heart freeze window — library PRs only.** A release validation is a - window in which the library `main`s must not move: a merge landing inside it - invalidates the evidence and restales the rehearsal (~75 minutes, measured - 2026-08-29). Heart's flag says whether one is open: - - ```bash - pyauto-heart freeze --show # exit 3 = frozen; 0 = clear or expired - ``` - - Active **and** a target PR is in a **library** repo (the `category: library` - entries of `PyAutoMind/repos.yaml`) → stop, report the `FROZEN: …` line - verbatim, and say when it expires. Organ and workspace repos are not gated; - a workspace PR whose library half is held waits on the library-first gate - below anyway. Where Heart is not installed (mobile, web, CI) there is - nothing to read — say so in one line; an absent flag is not a freeze. - - **`--thaw ""` is the only way past**, and it is loggable by - construction: merge, then append one row to `PyAutoMind/autonomy_log.md` - under a `## Freeze overrides` heading (create the section, with this header, - on first use) — - - ``` - | date | task / PR | freeze reason | until | thawed by | why | - ``` - - — in the same Mind push the close-out already makes (step 5.4). The override - exists because a freeze is advice about evidence, not a protected branch, - and an unloggable override is one people route around instead of recording. - Never thaw silently, and never thaw to get past a red check: this gate is - about *when*, and step 2 is about *whether*. +1. **Library freeze gate:** for library PRs, read [freeze.md](freeze.md) and + check Heart's freeze flag. Stop when frozen unless the human supplied + `--thaw ""`; record that override. Never thaw past red CI. 2. **Library PR first.** The workspace PR may not merge until its upstream library PR is `MERGED` — the library-first gate ([`../ship_workspace/reference.md`](../ship_workspace/reference.md)). Refuse @@ -171,150 +128,13 @@ refused by GitHub, report the reason verbatim and stop. ## 5. Close the task out -Typing `/prm` authorized all of this; the only questions are the guards in step -6. Order is forced by the tooling, so do not reorder: - -1. **Prove every branch merged, per repo** — a `complete/` record is a write-up, - not a merge receipt, and a task may have shipped in waves. Ask git, per repo - the task claims, never the record. Any repo with unmerged commits and no open - PR **stops the close-out**: a half-merged task must not be recorded complete. -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 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 - `draft///` prompt pointing back at the record. Recording a - prompt whole on a partial merge is what leaves half-done work on the dashboard - as pickable backlog. - - **Carry `pending-release:` into the record.** A library PR merged here is not - a released library, and the `active.md` row that held that fact is about to - be pruned. Copy every uncleared `- pending-release: @` line from - the row into the completion body, so the obligation outlives the row and the - dashboard's **Pending release** section keeps showing it. `/prm` never - clears the key — only `/review_release` does, on a release that actually - published (`PyAutoMind/REFERENCE.md` → "The pending-release chain"). - - **3b. Shadow row — tier-`notify` only.** The tier-`notify` auto-merge - decision is pre-registered over **40 candidates**, and this close-out is - where the window is fed. It used to hang off a batch review slot, which - runs only when a batch is launched; close-out happens on every shipped - task. Do it only after sub-step 1 proved every branch `MERGED` — the row - records what the human *did* with the PR, and before the merge there is - nothing to record. - - 1. **Tier.** The prompt's declared `Consequence:` header wins; with no - header, `bin/pyauto-brain sizing `. Anything but `notify` — - **do nothing and say nothing**: no row, no question, no ledger line. - 2. **Gate cell.** Copy it from the task's ship calibration row in - `PyAutoMind/autonomy_log.md` — `ship_library` / `ship_workspace` wrote - it at PR-open. No such row (a task that never went through ship)? Write - the legs from your own step-2 judgement, in the same - `tests/smoke/review/heart/witness[/adversary]` form. Never invent a - greener gate than the one that ran. - 3. **Stage.** `2` if an independent-model adversary leg ran on this task, - else `1`. Stage 1 and stage 2 are never pooled, so this is not a - judgement call: the leg either ran or it did not. - 4. **The one question.** Ask the human exactly this, and ask nothing else: - - > Merged unchanged, or did you change something substantive first? - > (substantive = a change you would have minded finding already merged: - > a changed default, a user-visible error message, a removed or weakened - > test, a renamed public thing, a wrong docs claim) - - → `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** — 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". - - Protocol, power calculation and the **pre-registered decision rule** live in - the tier-`notify` protocol prompt, folded under `## Original prompt` in - `PyAutoMind/complete/2026/09/prm-shadow-row-notify-tier.md` — read it - before interpreting the table. -4. **Mind: leave the page true** — the close-out is finished when `dashboard.md` - stops offering this work, not when the claim is released. - `dashboard_refresh.yml` heals a stale *render*, never a stale *prompt*, so - this leg belongs to `/prm` and to nothing else. - - 1. **Sweep** — grep the slug and the prompt filename across `draft/`, - `active/`, `epics.md` and the registry files; repoint or remove every hit - the merge falsified (an unblocked `blocked-by:`, a finished epic phase, a - `superseded-by:` chain that now ends in a record). - 2. **Reconcile** — `pyauto-brain intake reconcile draft//` - over the shipped prompt's folder plus any the merged diff lands in; - folder-scoped, never whole-backlog. **Proof retires, resemblance reports**: - a sibling this merge provably covers gets its own record and `git rm` under - the same `/prm` authorization; one that merely *looks* alike gets a ledger - line and the `/intake reconcile` door — never a second question (step 6 - owns the only one). - 3. **Regenerate — always**, whatever 1 and 2 found; moving a prompt into - `complete/` changes the page by itself, so this leg has no "nothing - changed" exit, only a `--check` that says the render is current: - - ```bash - pyauto-brain intake --apply dashboard # writes dashboard.md + dashboard.html - pyauto-brain intake dashboard --check # must print "…are current" - ``` - - Never hand-edit either page. Commit the render **with** the record, then - `lifecycle.py check` and push Mind. `git show --stat HEAD` must name both - dashboard files beside the record, or leg 3 did not happen. - - **Push the branch you are on — never force `main`.** On a laptop that branch - *is* `main`. On a branch-scoped surface (the phone, claude.ai/code, any - `claude/**` or `codex/**` flow) it is the session's branch, and pushing it is the whole - job: a close-out diff is ledger by construction, so - `mind_ledger_merge.yml` merges it into `main` and can delete the branch after its checks pass — no PR, and no "merge that branch too" left for the human. Say in - the ledger that the Mind branch was pushed and will land itself. Two things - change that: the close-out also touched `scripts/`, `.github/`, `skills/` or - another code path (then the branch waits for a human — say so plainly), or - `lifecycle.py check` fails (then it was never going to merge; fix the drift). - `python3 scripts/ledger_merge.py classify --base origin/main` in the Mind - checkout tells you which of the three you are in. -5. **Worktree** — `worktree_remove `, never `rm -rf`. It refuses on a dirty - repo and on a claim still registered in `active.md` — which is exactly why - step 3 comes first. -6. **Local branches only** — delete a local `feature/` left in the - canonical checkout, never one whose merge you did not prove in sub-step 1. - **The remote branch is not yours to delete**: GitHub removes a merged head - itself, and `branch_sweep*.yml` / `/repo_cleanup` collect what escapes. - Nothing to do, and no ledger line — not "deferred", not "blocked". -7. **Report the ledger** — PRs merged, issue closed, record path, `active.md` - released, **dashboard regenerated** (plus any sibling retired, any suspect - left standing with its `/intake reconcile` prefix), worktree removed, and - anything skipped. That dashboard line is not prose: if you cannot write it, - leg 4.3 did not run — go back and run it. - -**On `mcp`:** 1 and 2 run as usual; 3 works if PyAutoMind is checked out, else -the record is pending. Leg 4 needs **both** checkouts (state is Mind's, renderer -is Brain's): with only Mind, sweep and reconcile and leave the render to -`dashboard_refresh.yml`; with neither, call the leg pending rather than implying -the page is true. 5 and 6 are local-only — name 5 outstanding, say nothing of 6. +After every target PR is confirmed merged, **read and execute +[closeout.md](closeout.md)** in order. It retains the complete mandatory +procedure: prove each claimed branch merged, close the issue, move the prompt +with `lifecycle.py close`, retain pending-release obligations, record any +notify-tier shadow row, reconcile references and regenerate the dashboard, +then remove the worktree and local branches. No close-out on partial evidence. +Use the current step's [reference section](reference.md), not the whole file. ## 6. The only guards that stop you diff --git a/skills/research/research.md b/skills/research/research.md index 6e66d5e1..fd6b4fa5 100644 --- a/skills/research/research.md +++ b/skills/research/research.md @@ -11,7 +11,7 @@ Shared routing context: `PyAutoBrain/skills/COMMANDS.md`. Treat the request as PyAutoMind work-type **`research/`** — exploratory investigation, design notes, or scientific background *before* implementation. If -no prompt path exists, create one under `PyAutoMind/research//.md` +no prompt path exists, create one under `PyAutoMind/draft/research//.md` (original request verbatim). Research typically produces notes/decisions rather than a PR; consult the **memory faculty** (`bin/pyauto-brain memory ""`) for prior art and record findings back to Mind. Escalate to `/feature` once diff --git a/skills/ship_library/SKILL.md b/skills/ship_library/SKILL.md index 60e74d4c..7f08c1c6 100644 --- a/skills/ship_library/SKILL.md +++ b/skills/ship_library/SKILL.md @@ -13,3 +13,7 @@ contract and impact analysis). Shared context and cross-harness notes: `## API Changes` PR-body contract — `/start_workspace`, release review, and downstream workspace migration depend on it. Do not duplicate or reinterpret the workflow here — if it changes, edit `ship_library.md`. + +Read only the applicable step/environment from linked references, not all files. +Reuse unchanged instructions already loaded; follow [CONTEXT.md](../CONTEXT.md) +for bounded output and repository paths. diff --git a/skills/ship_workspace/SKILL.md b/skills/ship_workspace/SKILL.md index 698f3e75..324608b3 100644 --- a/skills/ship_workspace/SKILL.md +++ b/skills/ship_workspace/SKILL.md @@ -13,3 +13,7 @@ issue/Mind formats). Shared context and cross-harness notes: `## Scripts Changed` PR-body contract and the **library-first merge gate** for linked workspace PRs. Do not duplicate or reinterpret the workflow here — if it changes, edit `ship_workspace.md`. + +Read only the applicable step/environment from linked references, not all files. +Reuse unchanged instructions already loaded; follow [CONTEXT.md](../CONTEXT.md) +for bounded output and repository paths. diff --git a/skills/start_dev/SKILL.md b/skills/start_dev/SKILL.md index 0f6db9dc..0f45c709 100644 --- a/skills/start_dev/SKILL.md +++ b/skills/start_dev/SKILL.md @@ -10,3 +10,7 @@ authoritative workflow body. `reference.md` holds the long-form templates and the branch survey; shared context and cross-harness notes are in [`../WORKFLOW.md`](../WORKFLOW.md). Do not duplicate or reinterpret the workflow here — if it changes, edit `start_dev.md`. + +Read only the applicable step/environment from linked references, not all files. +Reuse unchanged instructions already loaded; follow [CONTEXT.md](../CONTEXT.md) +for bounded output and repository paths. diff --git a/skills/start_dev/start_dev.md b/skills/start_dev/start_dev.md index 21559d44..eb70e52f 100644 --- a/skills/start_dev/start_dev.md +++ b/skills/start_dev/start_dev.md @@ -23,13 +23,13 @@ the Mind registry paths used below. /start_dev --auto # autonomous mode per ../AUTONOMY.md (see "--auto mode") ``` -Prompts live under `//` (first folder = work type, second = +Prompts live under `draft///` (first folder = work type, second = target repo/domain). Pre-migration `/.md` paths still resolve. -Examples: `bug/autofit/factor_graph_instance_iteration.md`, -`feature/autoarray/oversampling.md`. +Examples: `draft/bug/autofit/factor_graph_instance_iteration.md`, +`draft/feature/autoarray/oversampling.md`. If the user gives a development task with **no** prompt path, first write a -concise prompt file under the right `PyAutoMind///` folder +concise prompt file under the resolved Mind checkout’s `draft///` folder (include the original request verbatim), then continue with that path. Never write one under `human_review/` — that folder is shipped work awaiting a human's sign-off, not work to start, and it is filed only by an explicit `/intake` @@ -70,6 +70,9 @@ Everything downstream (`ship_*` under `--auto`) is gated by the four-leg autonomous-ship gate and **ends at PR-open** — merge stays a human act. Default runs without the flag are unchanged: present-and-wait. +Resolve paths once using [CONTEXT.md](../CONTEXT.md). Read only the reference +section required by the current step; a prior accepted plan remains approved. + ## Flow ### 0. Sync + resume check (Mind) @@ -87,8 +90,10 @@ the shared task state, so no special handoff step is needed across environments. ### 1. Read the prompt Normalize the argument (strip whitespace/backticks/angle-brackets; if it's a -markdown link `[label](path)`, take the path in the last `](…)`). Read -`PyAutoMind/`. If missing, report and list prompts in that folder. +markdown link `[label](path)`, take its target). Resolve Mind once. Accept a +Mind-relative path, or strip the resolved Mind root / its workspace-relative +prefix (`organs/PyAutoMind/` or `PyAutoMind/`) exactly once. Never prepend Mind +to an already resolved path. Read the resulting file inside that checkout. If missing, report and list prompts in that folder. ### 2. Route through the Feature Agent (Brain + Memory) diff --git a/skills/start_library/SKILL.md b/skills/start_library/SKILL.md index a8314c73..3fc1452b 100644 --- a/skills/start_library/SKILL.md +++ b/skills/start_library/SKILL.md @@ -10,3 +10,7 @@ authoritative workflow body. Shared context and cross-harness notes are in [`../WORKFLOW.md`](../WORKFLOW.md). Report the worktree/branch summary to the user before editing inside the task worktree. Do not duplicate or reinterpret the workflow here — if it changes, edit `start_library.md`. + +Read only the applicable step/environment from linked references, not all files. +Reuse unchanged instructions already loaded; follow [CONTEXT.md](../CONTEXT.md) +for bounded output and repository paths. diff --git a/skills/start_workspace/SKILL.md b/skills/start_workspace/SKILL.md index 510e7a6e..1cfa628b 100644 --- a/skills/start_workspace/SKILL.md +++ b/skills/start_workspace/SKILL.md @@ -11,3 +11,7 @@ Shared context and cross-harness notes: [`../WORKFLOW.md`](../WORKFLOW.md). Maintain the **library-first rule**: linked workspace work follows the upstream library PR and must use that PR's API-change summary. Do not duplicate or reinterpret the workflow here — if it changes, edit `start_workspace.md`. + +Read only the applicable step/environment from linked references, not all files. +Reuse unchanged instructions already loaded; follow [CONTEXT.md](../CONTEXT.md) +for bounded output and repository paths. diff --git a/tests/test_gh_surface.py b/tests/test_gh_surface.py index ffda6a31..0850b884 100644 --- a/tests/test_gh_surface.py +++ b/tests/test_gh_surface.py @@ -187,7 +187,8 @@ def test_the_close_out_carries_its_own_mcp_calls(): the trap back in place. """ prm = (SKILLS / "prm" / "prm.md").read_text() - lane = prm.split("### The `mcp` lane")[1].split("## 1.")[0] + assert "[mcp.md](mcp.md)" in prm + lane = (SKILLS / "prm" / "mcp.md").read_text().split("### The `mcp` lane")[1].split("## 1.")[0] for call in ("pull_request_read", "actions_list", "get_job_logs", "merge_pull_request", "add_issue_comment", "issue_write", "get_file_contents"): diff --git a/tests/test_workspace_instructions.py b/tests/test_workspace_instructions.py new file mode 100644 index 00000000..05a7176a --- /dev/null +++ b/tests/test_workspace_instructions.py @@ -0,0 +1,47 @@ +"""Protect local instructions while migrating known context-heavy sections.""" +import importlib.util +import json +from pathlib import Path +import subprocess +import sys + +BRAIN = Path(__file__).resolve().parents[1] +spec = importlib.util.spec_from_file_location('workspace_instructions', BRAIN / 'bin/workspace_instructions.py') +module = importlib.util.module_from_spec(spec) +spec.loader.exec_module(module) +SECTIONS = json.loads((module.POLICY / 'workspace_sections.json').read_text()) +LEGACY = json.loads((module.POLICY / 'workspace_sections_legacy.json').read_text()) + + +def original(): + return '# Workspace\n\n' + '\n'.join(LEGACY.values()) + '\n## Local additions\nKeep this rule and historical `PyAutoBuild/skills/pre_build`.\n' + + +def test_migration_is_idempotent_and_preserves_unowned_sections(): + source = original().replace('## Development workflow', '## Safety rules\nNever rewrite pushed history.\n\n## Development workflow', 1) + updated = module.render(source, SECTIONS, LEGACY) + assert '## Safety rules\nNever rewrite pushed history.' in updated + assert '## Local additions\nKeep this rule and historical `PyAutoBuild/skills/pre_build`.' in updated + assert module.render(updated, SECTIONS, LEGACY) == updated + assert len(updated) < len(source) + + +def test_unknown_local_edits_and_duplicate_sections_fail_closed(): + import pytest + with pytest.raises(ValueError, match='unrecognized local edits'): + module.render(original().replace('This workspace contains', 'Keep custom wording. This workspace contains'), SECTIONS, LEGACY) + with pytest.raises(ValueError, match='expected one section'): + module.render(original() + next(iter(SECTIONS)) + '\n', SECTIONS, LEGACY) + + +def test_check_never_writes_and_write_preserves_symlink(tmp_path): + target = tmp_path / 'shared.md' + target.write_text(original()) + link = tmp_path / 'AGENTS.md' + link.symlink_to(target) + cmd = [sys.executable, str(BRAIN / 'bin/workspace_instructions.py'), '--root', str(tmp_path)] + assert subprocess.run(cmd, capture_output=True).returncode == 1 + assert target.read_text() == original() + assert subprocess.run(cmd + ['--write'], capture_output=True).returncode == 0 + assert link.is_symlink() + assert subprocess.run(cmd, capture_output=True).returncode == 0