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
20 changes: 16 additions & 4 deletions AUTONOMY.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,10 @@ names are unaffected, and so is the rest of the 2026-11-04 grant. The
public-API rule "not adopted" on 2026-11-04 is adopted now, in this narrower
form.

**Enforcement.** Until the close-out and review checks detect this from the
diff (PyAutoMind `draft/feature/pyautobrain/glance_public_name_check.md`), the
shipping session or the watcher's close-out applies it by reading the diff.
Doubt means `/prm`.
**Enforcement.** Enforced by `bin/public_names.py` (PyAutoBrain#641): the
shift watcher runs it before any close-out session spawns, and refuses on an
added or renamed name or a diff it cannot read, and the ship skills and `/prm`
"Tiered merge" run it as a stop. Doubt means `/prm`.

## Stage-2 adversary amendment — 2026-11-04

Expand Down Expand Up @@ -979,6 +979,18 @@ one comments read or one status write in a tick, and a command enacted from
any other login or enacted twice: any of these retires the watcher to fake
mode.

**Amendment — 2026-11-16 (PyAutoBrain#641), approved by the human.** For the
"Public-name narrowing of `glance` — 2026-11-16", the watcher may also make
read-only `gh api` GET calls (the PR itself for its base and head shas,
`compare` to find the merge base, the PR's file list, the before/after file
contents, and one `contents/<package>` read at head to confirm the package
directory exists) on the **library** PRs its own
workers named, once per close-out and before any close-out session spawns.
These calls make no writes, and a call that fails gives "cannot tell", which
refuses the merge. A PR in any other repo makes no call at all. The revert
condition covers these the same way: any other call, or a repeat for the same
close-out, retires the watcher to fake mode.

## Human override for Heart RED (development only)

Heart RED still parks every autonomous run and blocks every release. After the
Expand Down
39 changes: 37 additions & 2 deletions agents/conductors/batch/_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ def closeout_prompt(task: str, pr_url: str, prompt_path: str, brief_path: Path,
"""The close-out session template filled in for one PR (phase 4b). Its
Heart check is the scoped development-ship gate for the PR's repo (leg 4,
PyAutoHeart#340): only `green` merges. Its CI check is `pyauto-brain
ci-verdict` on the PR (PyAutoBrain#628): only `GREEN` merges."""
ci-verdict` on the PR (PyAutoBrain#628): only `GREEN` merges. Its
public-name check is `pyauto-brain public-names` (PyAutoBrain#641): an
added or renamed public library name, or a diff it cannot read, refuses."""
repos = pr_repos(pr_url)
heart_cmd = (f"bash -c 'source \"{COMMON_SH}\"; consult_vitals_verdict --repos {repos}'"
if repos else "")
Expand All @@ -298,6 +300,8 @@ def closeout_prompt(task: str, pr_url: str, prompt_path: str, brief_path: Path,
shift_ledger=SHIFT_LEDGER, pr_repos=repos or "(none — not a GitHub PR URL)",
heart_cmd=heart_cmd or "(cannot be scoped — refuse)",
ci_verdict_cmd=f"{BRAIN_CLI} ci-verdict {pr_url}" if repos
else "(not a GitHub PR URL — refuse)",
public_names_cmd=f"{BRAIN_CLI} public-names {pr_url}" if repos
else "(not a GitHub PR URL — refuse)")


Expand Down Expand Up @@ -398,16 +402,38 @@ def run_scoped(run, argv: list[str], task: str, **kw):
return res


#: The verdict fields of a close-out the watcher refused before any session.
PRESPAWN_GATE = "public-name check (watcher, before spawn)"
PRESPAWN_MODEL = "none — no close-out session started"


def public_names_gate(pr_url: str, check=None) -> str:
"""The deterministic public-name check (AUTONOMY.md "Public-name
narrowing of `glance` — 2026-11-16", PyAutoBrain#641) on one PR, run by
the watcher before a close-out session spawns: '' to go on, else the
refusal's `why`. A repo outside the ruled libraries goes on; a hit or a
check that cannot tell refuses."""
try:
if check is None:
sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "bin"))
import public_names as check # noqa: E402 — bin/, beside ci_verdict.py
v = check.for_pr(pr_url)
except Exception as e: # anything unexpected: fail closed
return f"public-name check could not tell: {str(e)[:200]} → human /prm"
return check.reason(v) if v.get("verdict") != "CLEAN" else ""


class RealSpawner:
"""`claude --bg` workers from the session template (phase 3b)."""

real = True

def __init__(self, brief_path: Path, mode: str, cwd: Path | None = None, run=None,
gh=None):
gh=None, public_names=None):
self.brief_path, self.mode, self.cwd = Path(brief_path), mode, cwd
self.run = run or subprocess.run
self.gh = gh or gh_pr_state
self.public_names = public_names or public_names_gate

def pr_state(self, url: str) -> dict | None:
"""GitHub's word on a PR — the merge truth for a close-out (#603)."""
Expand All @@ -431,6 +457,15 @@ def spawn(self, task: str, prompt_path: str, lease_dir: Path,
return {"pid": 0, "agent_id": m.group(1), "session_id": None, "mode": self.mode}

def spawn_closeout(self, task: str, pr_url: str, prompt_path: str, lease_dir: Path) -> dict:
# The public-name check runs here, deterministically, before any
# session (#641): a hit or a cannot-tell is this PR's refusal, written
# as the verdict a close-out would write, and nothing is spawned.
why = self.public_names(pr_url)
if why:
verdict = {"result": "refused", "pr": pr_url, "why": why,
"gate": PRESPAWN_GATE, "model": PRESPAWN_MODEL}
(Path(lease_dir) / f"{task}.closeout").write_text(json.dumps(verdict))
return {"pid": 0, "agent_id": None}
argv = closeout_command(task, pr_url, prompt_path, self.brief_path, lease_dir,
self.mode)
# The same scoped route as a worker (#634): a close-out may be the
Expand Down
11 changes: 10 additions & 1 deletion agents/conductors/batch/closeout_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ outcome — the human merges by `/prm` at check-in.
head. Record what decided it.
2. Review the diff adversarially: look for a changed default, a user-visible
error message, a removed or weakened test, a renamed public thing, or a
wrong docs claim. Any one of them → refuse.
wrong docs claim. Any one of them → refuse. Added or renamed public
library names are decided by the one check (AUTONOMY.md "Public-name
narrowing of `glance` — 2026-11-16", PyAutoBrain#641). The watcher ran it
before starting you; run it again, as a second layer:

{public_names_cmd}

Exit 0 passes (a repo the ruling does not cover prints CLEAN). Exit 1 (a
public name added or renamed) or 2 (it cannot tell) refuses, with its first
output line as the `why`: `public name added/renamed: <names> → human /prm`.
3. Refuse if the PR carries the `decision-taken` label, if its tier is not
`glance`, or unless Heart's **scoped development-ship verdict** for the
PR's repo ({pr_repos}) is `green` (AUTONOMY.md leg 4, PyAutoHeart#340):
Expand Down
7 changes: 6 additions & 1 deletion agents/faculties/review/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ Heart and the agent reasons over the verdict.
or, for an in-place task with no worktree, the checkouts its `active.md`
`- repos:` block claims — or explicit repo paths and emits, per repo: merge-base against `origin/main`, commits
ahead, diff stat, changed files, and risk flags (public-API-shaped paths,
config/schema files, tests changed or not, generated files).
config/schema files, tests changed or not, generated files). For a
library repo it also lists the **public-name delta** (`public_names`,
from `bin/public_names.py`, PyAutoBrain#641): an added or renamed public
name raises `public-name-added-or-renamed`, and the merge is a human
`/prm` whatever the tier (AUTONOMY.md "Public-name narrowing of `glance`
— 2026-11-16"). Say so in the verdict; it is not a code finding.
2. The reviewing agent runs, over that surface: a **code review at high
effort** (correctness first, then reuse/simplification) and a **verify
pass** — drive the affected flow end-to-end, not just tests (for
Expand Down
29 changes: 29 additions & 0 deletions agents/faculties/review/_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
import _pyauto_root # noqa: E402

# The one public-name check (PyAutoBrain#641), shared with the close-out and
# the tiered merge; it lives beside ci_verdict.py in bin/.
sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "bin"))
import public_names # noqa: E402

WT_BASE = _pyauto_root.pyauto_wt_root()

# Paths that smell like public API / behaviour when changed — flags only,
Expand Down Expand Up @@ -113,6 +118,11 @@ def repo_surface(repo: Path) -> dict | None:
flags.append(name)
if any(f.endswith(".py") and "test" not in f.lower() for f in changed):
flags.append("python-source")
names = public_name_delta(repo, base)
if names and names["verdict"] == public_names.HIT:
flags.append("public-name-added-or-renamed")
elif names and names["verdict"] == public_names.CANNOT:
flags.append("public-names-cannot-tell")
return {
"repo": repo.name,
"path": str(repo),
Expand All @@ -124,9 +134,22 @@ def repo_surface(repo: Path) -> dict | None:
"files": files,
"risk_flags": flags,
"claims_to_falsify": claims,
**({"public_names": names} if names else {}),
}


def public_name_delta(repo: Path, base: str) -> dict | None:
"""The public-name delta of a library repo's branch (AUTONOMY.md
"Public-name narrowing of `glance` — 2026-11-16"): added and renamed
names send the merge to a human `/prm`. None for a repo the ruling does
not cover."""
v = public_names.for_range(repo, f"{base}..HEAD")
if v.get("not_library"):
return None
keep = ("verdict", "added", "renamed", "removed", "cannot_tell")
return {**{k: v[k] for k in keep}, "reason": public_names.reason(v)}


def in_place_repos(task: str) -> list[Path]:
"""Checkouts claimed by an in-place task (worktree: none) in active.md.

Expand Down Expand Up @@ -208,6 +231,12 @@ def emit_human(surfaces: list[dict], witness: str = "", adversary: bool = False)
print(f" {f}")
if len(s["files"]) > 40:
print(f" ... and {len(s['files']) - 40} more")
names = s.get("public_names")
if names:
print(f" public names: {names['verdict']}"
+ (f" — {names['reason']}" if names["reason"] else ""))
for e in names["removed"]:
print(f" info — removed: {e['module']}.{e['name']}")
claims = s.get("claims_to_falsify") or []
if claims:
print(" claims to falsify (adversarial pass — for EACH: what would")
Expand Down
8 changes: 8 additions & 0 deletions bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Executable tooling for the PyAuto organism.
mergeability → GREEN / PENDING / RED with reasons; exit 0 · 2 · 1. `/prm`
step 2 and the shift close-out run it; the watcher's `pr_health` feeds its
`gh pr checks` rows to the same `judge`.
- **`public_names.py`** — `pyauto-brain public-names <owner/repo>#<n>`, or
`--repo <path> --range a..b`: does a change add or rename a public name in
a library package (PyAutoBrain#641; AUTONOMY.md "Public-name narrowing of
`glance` — 2026-11-16")? `ast` over each changed module before and after;
exit 0 CLEAN (or not a library repo) · 1 HIT · 2 cannot tell. The shift
watcher refuses on 1 or 2 before any close-out session spawns, the
close-out and the in-turn tiered merge stop on them too, and the review
faculty lists the delta in its ReviewSurface.
- **`lane_backfill.py`** — proposes a `Lane:` for every lane-less draft in
the planner pool, from intake's own lane signals, as a table for a human to
skim; `--apply [--from <table>]` writes the headers (commits nothing).
Expand Down
Loading
Loading