Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 52 additions & 18 deletions skills/GITHUB_ACCESS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
# GitHub access: `gh` is not always there
# GitHub access: operations first, clients second

Shared by every skill that touches GitHub. Read this once, at the top of a run,
and act on what it says for the rest of the run.

## The problem this page exists for
## Canonical contract

The workflow asks for **GitHub operations**, not a particular client. Resolve
the authenticated GitHub-control surface once, then keep using it consistently:

1. a local shell may have authenticated `gh`;
2. a remote/chat harness may expose native GitHub actions/tools instead, with a
repository scope and a read/write subset fixed by that connection;
3. a surface may be read-only or have no GitHub write capability at all.

Do not infer permissions from "ChatGPT", "Codex", "Claude", mobile, web, or a
model name. Inspect the actions/permissions actually exposed. Do not perform a
dummy write just to probe access: use the first required operation, and if the
provider denies it, downgrade that capability and route the missing phase.

The `gh` commands in skill bodies are executable commands only on the first
surface. Elsewhere they name the operation to perform. The MCP column below is
one measured adapter, not the architecture; another connected GitHub surface
may expose equivalent actions under different names.

**No API fallback:** GitHub access in the ordinary-Chat route must never be
replaced with the OpenAI API, an OpenAI API key, ChatGPT browser automation, or
session-credential reuse. Those are not GitHub clients and are not execution
fallbacks.

## The remote-session problem this page originally existed for

Most of the workflow was written on a developer box, where `gh` is installed and
authenticated, so the skills spell their GitHub steps as `gh` commands — 19 skill
Expand All @@ -24,20 +49,27 @@ completion record logged it after the fact:
So: decide once, up front, which surface you have, and read the procedure
through that lens.

## Decide once, at the start of the run
## Resolve the GitHub-control surface once

When a shell is available, the established probe remains:

```bash
command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1 \
&& echo "gh" || echo "mcp"
&& echo "gh" || echo "native-tools"
```

- **`gh`** — follow the skill's commands as written.
- **`mcp`** — the `gh` lines are *the operation to perform*, not the command to
run. Translate with the table below. Do not try to install `gh` (the next
section says why it would not help), and do not report the task as blocked: the MCP surface can do everything the close-out
needs — deleting a branch is not one of the things it needs (below).

A session cannot be half-and-half. Probe once; don't re-probe per step.
- **native GitHub actions/tools** — treat each `gh` line as the operation to
perform and translate it to the equivalent authenticated action. The mapping
below records the currently measured MCP names; use equivalent operations on
another connected surface.
- **no matching write action** — the current surface is not repository-write /
GitHub-control capable for that phase. Do not install credentials, improvise a
browser automation route, or call an OpenAI API; use the bounded execution
handoff or stop.

Select one authenticated control surface for the run and do not mix credentials
or raw-token workarounds. Do not re-probe per step.

## Installing `gh` does not work — measured, 2026-08-27

Expand Down Expand Up @@ -85,7 +117,7 @@ straight into the 403s above — the failure mode the probe exists to prevent.
The probe is only honest while `gh` is absent, which is the strongest reason to
leave it that way.

## The mapping
## Measured `gh` ↔ MCP adapter mapping

| Operation | `gh` | MCP tool |
|---|---|---|
Expand Down Expand Up @@ -117,8 +149,10 @@ leave it that way.
| Create, answer or convert a Discussion | `gh api graphql` (`createDiscussion`) / the issue sidebar | **nobody in a session** — REST Discussions is read-only, GraphQL is refused; the human clicks (`PyAutoMind/policy/community_surface.md`) |
| Be woken by CI / comments on a PR | *(no equivalent — a CLI polls)* | `subscribe_pr_activity`, `unsubscribe_pr_activity` exist but are **not to be armed** — sessions end at their deliverable; use `unsubscribe_pr_activity` only to clear a stale subscription |

Tool names are given unprefixed; the harness exposes them as
`mcp__github__<name>`. If a name is not loaded, `ToolSearch` fetches its schema.
Tool names are given unprefixed for the measured MCP adapter; that harness
exposes them as `mcp__github__<name>`. Other connected GitHub surfaces may use
different action names. Match operation semantics and permissions, not these
wire names.

That last row is the one capability a run must **not** take. A subscription or
a `send_later` reminder outlives the session's deliverable and wakes turns
Expand Down Expand Up @@ -160,12 +194,12 @@ against `gh api repos/...` REST paths runs in a remote session by pointing
repository set at start; `add_repo` extends it. A call outside that scope is
denied — that is the scope working, not an auth problem to route around.

## Two rules that apply on both surfaces
## Two rules that apply on every surface

1. **Every comment, review or reply you author ends with the attribution
footer** — a blank line, a `---` rule, then
`_Generated by [Claude Code](https://claude.ai/code)_`. The server strips
duplicates, so include it even where the tool adds one.
1. **Do not fabricate harness attribution.** If repository policy requires an
attribution footer, identify the actual harness when it is known; otherwise
use the repository's provider-neutral wording. Never stamp a Chat/Codex run
as Claude (or vice versa) merely because an older adapter example did.
2. **Be frugal.** Post when a round resolves the task, hits a real blocker, or
raises a question. The diff is the record; don't narrate each fix.

Expand Down
32 changes: 32 additions & 0 deletions skills/MODEL_DELEGATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,38 @@ review faculty remains independent for both provider families.
No default is defined for other model families. If a requested worker is not
available, execute in-session without changing safety or approval gates.

## Cross-environment capability handoff

A missing execution capability does not make the execution environment the new
orchestrator. The current scientist-facing session keeps planning, Mind state,
approval gates and final judgment; hand off only the smallest coherent phase
whose required evidence cannot be produced here.

A cross-environment packet carries:

- the existing Mind task / issue;
- repository, branch and exact starting commit;
- one coherent objective and permitted files/scope;
- required commands, runtime/scientific checks or review question;
- explicit "do not broaden/redesign unrelated work";
- requested return: resulting commit/diff (if any), pass/fail counts and only
decision-relevant failure/environment evidence.

The receiving environment resumes the existing branch; it does not create a
second task or lifecycle. The orchestrator consumes the returned evidence and
continues the same Brain → review/vitals → Heart → PR flow.

**Independent review is a separate capability.** A conversation that authored
the branch cannot satisfy the independent-review leg by rereading its own diff.
If no independent worker/reviewer is available in the current surface, hand off
only the review phase or require human review.

**No OpenAI API fallback.** An ordinary ChatGPT orchestration route must never
turn a missing worker/runtime into an OpenAI SDK, Responses API,
`OPENAI_API_KEY`, browser/session automation or other separately billed API
call. Use an explicitly chosen supported execution surface or stop at the
missing phase.

## Bounded worker contract

- Pass only the worktree, affected files, accepted plan, required commands,
Expand Down
79 changes: 73 additions & 6 deletions skills/WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,70 @@ bin/pyauto-brain build --dry-run
If Brain is unavailable, emulate the requested decision from its `AGENTS.md`
and this file, and say that it was emulated.

## Orchestration capabilities and execution evidence

The **orchestration environment** is the scientist-facing session currently
driving the task. The **execution environment** is wherever a particular phase
obtains the evidence it needs. They may be the same place, but they need not be.
Neither is an organ and neither owns task state: Mind remains the sole lifecycle
record.

Reason about capabilities, not product names. Probe the current surface once and
use only capabilities it actually exposes:

- `repository-read` / `repository-write` — inspect or change repository files;
- `github-control` — branches, commits, issues, PRs, reviews and Actions state;
- `local-filesystem` / `shell-runtime` — checkout-local files, commands and imports;
- `test-execution` — unit/integration/smoke commands in a real runtime;
- `worktrees` — isolated local task checkouts;
- `independent-review` — a reviewer genuinely independent of the authoring context;
- `remote-compute` — SSH/HPC/GPU or other environment-specific execution.

A model/provider/app name does not imply any item in that list. In particular, a
connected Chat surface may expose read-only GitHub access, read/write GitHub
actions, or no GitHub action at all. Detect what is present; fail closed on what
is absent.

For each phase, identify the **required evidence** first. Stay in the current
orchestration environment when its capabilities can honestly produce it. An
existing repository CI workflow on the exact branch head may provide applicable
test/smoke evidence when it runs the required scope; verify the head SHA and
individual legs rather than treating "CI green" as a generic proof. Do not add a
throwaway workflow merely to obtain a shell.

When a capability is missing, delegate the **smallest coherent phase** that
needs it and return its diff/commit plus decision-relevant evidence to the same
Mind task. If substantial implementation itself is runtime-dependent
(scientific/numerical debugging, profiling, HPC, environment inspection,
generated artefacts), route that coherent phase to an execution environment
from the outset; Chat or another orchestration surface can still retain the
Brain decisions and user conversation.

Independent review is evidence, not a second look by the author: the same
conversation that wrote a branch cannot self-certify the review faculty's
independence. Delegate only the review phase when that is the sole missing
capability.

**Heart remains separate from CI.** Exact-head CI can satisfy applicable test or
smoke evidence; it never substitutes for the authoritative Heart verdict. If the
current surface cannot read fresh authoritative Heart evidence, obtaining that
evidence is itself a bounded missing-capability step.

`Lane:` remains an intrinsic scheduling requirement (`any` or `local-dev`)
for a task that genuinely needs local data/output/SSH resources. It is not the
name of the orchestrating product and must not grow a `chatgpt`, `codex` or
`claude` value.

### No OpenAI API fallback

The ordinary-Chat route has **no API billing path**. Never use an OpenAI SDK,
Responses API, API Platform key, `OPENAI_API_KEY`, browser/session credential
reuse, or a local Brain process that programmatically starts a ChatGPT
conversation as a fallback. If the current Chat lacks a capability, use only an
explicitly selected supported execution surface (for example existing GitHub
Actions, Codex/Work, local shell or HPC) or stop at that phase. This invariant
does not depend on the user's API billing settings.

## Model delegation

Provider policies are intentionally asymmetric. Anthropic retains mandatory
Expand Down Expand Up @@ -80,10 +144,11 @@ review, and Heart form the ship gate. Merge is always a current human action.
- Plan Mode means present-and-wait unless explicit `--auto` changes that gate.
- With no prompt, first create a concise Mind draft containing the original
request verbatim.
- If a requested worker is unavailable, execute directly without weakening
permissions, review, or health gates.
- `gh` commands name GitHub operations; remote sessions translate them through
`GITHUB_ACCESS.md`.
- If a requested worker is unavailable, execute directly only when the current
surface has the required capability; otherwise use the bounded cross-environment
handoff in `MODEL_DELEGATION.md` or stop without weakening any gate.
- `gh` commands name GitHub operations; map those operations onto the authenticated
GitHub-control surface actually available via `GITHUB_ACCESS.md`.

## Task state and worktrees

Expand All @@ -98,8 +163,10 @@ claim; tasks touching the same repo serialize unless a human explicitly
authorizes coordination. Source the generated `activate.sh` before Python or
tests.

In web/CI sessions, use available clones and explicit cache/PYTHONPATH settings.
The same Mind registry provides continuity across environments.
In web/CI sessions with clones, use those clones and explicit cache/PYTHONPATH
settings. A GitHub-control-only session may have no clone at all: it operates on
remote branches/files and records no fake `worktree:` path. The same Mind
registry and branch/commit provide continuity across environments.

## Repository routing

Expand Down
55 changes: 37 additions & 18 deletions skills/ship_library/ship_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ WT_ROOT=~/Code/PyAutoLabs-wt/<task-name>
source "$WT_ROOT/activate.sh"
```

Legacy entries with no `worktree:` fall back to the main checkouts — warn that
the task pre-dates the worktree flow and is not parallel-safe. In other execution
environments (web-github / ci-only), use the working-directory clones with
`PYTHONPATH` exported (WORKFLOW.md).
A task with a real `worktree:` uses it. A clone+shell surface without a task
worktree may use its working-directory clone with the documented environment
settings. A **GitHub-control-only** task deliberately has no `worktree:`:
resolve each claimed `repos:` branch and exact head commit through GitHub,
inspect its diff against `main`, and never fall back to a canonical local
checkout that this surface does not possess.

### 2. Draft commit message + PR body (reasoning model)

Expand Down Expand Up @@ -62,23 +64,40 @@ tests/smoke/review, a live human may authorize the canonical `AUTONOMY.md`
"Corrective-PR exception for Heart RED" for a causal fix. Follow the selected
canonical section's scope and four record sinks exactly. Neither path permits
release or bypassing CI; merge requires its own current human command and green
required GitHub checks. If `pyauto-brain`/`pyauto-heart` are
unavailable, run the per-repo `pytest <test_dir>/ -x` inside the worktree as the
gate and treat any failure as RED (WORKFLOW.md). Under `--auto`, this step is
the four-leg **autonomous-ship gate** — tests (+ downstream dependents on
public-API changes), smoke, review-faculty CLEAN, Heart — per
`AUTONOMY.md` "The autonomous-ship gate"; do not restate it here.
required GitHub checks. If the organism CLIs are unavailable, use WORKFLOW.md's capability/evidence
rules rather than weakening the gate:

- a runtime-capable surface runs the required per-repo tests/smoke directly;
- a no-runtime GitHub-control surface may consume **existing exact-head GitHub
Actions evidence** only when the workflow/legs cover the required test scope;
verify the branch head SHA and each relevant conclusion;
- if the required execution evidence is absent, hand off only that validation
phase;
- CI is never a Heart verdict. Read fresh authoritative Heart readiness evidence
from an available Heart surface; if that cannot be obtained here, obtain only
that bounded evidence before shipping.

Under `--auto`, this step is the four-leg **autonomous-ship gate** — tests
(+ downstream dependents on public-API changes), smoke, review-faculty CLEAN,
Heart — per `AUTONOMY.md` "The autonomous-ship gate"; do not restate it here.
A same-conversation reread is not an independent review.

### 4. Execute the ship (feature-dev)

On GREEN, run the dev workflow's own test → commit → push → feature-PR step per
[`reference.md`](reference.md) → "Execution contract": run tests inside the
worktree, confirm the branch is `feature/<task-name>` (never auto-switch),
commit, push, `gh pr create --label pending-release`, and verify the label
landed. This is feature-development git work, not a Build/release step. In
local-dev Anthropic delegates the mechanical part to its execution tier;
OpenAI runs it inline unless a bounded exception applies. Elsewhere run it
directly. If any step fails, stop and report — do not proceed.
On a Heart outcome permitted by WORKFLOW.md / AUTONOMY.md, execute the dev
workflow's test/evidence → commit/push → feature-PR step per
[`reference.md`](reference.md) → "Execution contract". A local worktree runs
the commands there. A GitHub-control-only surface verifies the existing remote
feature branch and exact head, uses repository/GitHub write operations for the
remaining commit/PR mechanics, and verifies required exact-head Actions
evidence. It must not claim a local test it did not run. If generation, imports
or another runtime step is still required, perform the bounded execution
handoff before PR-ready status.

This is feature-development git work, not a Build/release step. Provider model
delegation still follows MODEL_DELEGATION.md; capability absence is handled by
its cross-environment handoff rather than by provider-name conditionals. If any
step or evidence leg fails, stop and report — do not proceed.

**Under `--auto`:** all four legs of the autonomous-ship gate must pass — **five under a batch launch**, which adds the independent-adversary leg (`AUTONOMY.md` leg 5) — (step
3 note); then ship **without interactive sign-off** — the PR body additionally
Expand Down
Loading
Loading