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
105 changes: 93 additions & 12 deletions AUTONOMY.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,18 +334,25 @@ never an assumption:
`claims to falsify`, CLEAN carries one disposition line per claim
(basis-cited / idle / finding — faculty AGENTS.md step 2a); a bare CLEAN
over a non-empty claims surface is malformed evidence, not CLEAN.
4. **Heart** — verdict **GREEN** or **STALE**, or **YELLOW whose reason set is
contained in the set the human acknowledged at launch**. Heart observes
organism state, not the branch (the audit confirmed its legs never see
feature branches). **STALE** is Heart's freshness tier (evidence missing or
expired, nothing known-bad — `PyAutoHeart/heart/readiness.py`): it passes
this leg because an evidence gap is organism-scope, not branch-scope, and
legs 1–3 gate the branch itself; the PR body lists the stale reasons.
Releases are unaffected — they always require GREEN. A verdict from a Heart
without the tier behaves as before. For YELLOW, the acknowledgement binds
to the *exact reason list* at launch, for that launch only — any new
reason, or RED, parks the run. Never ambient, never carried across
sessions.
4. **Heart** — the **scoped development-ship verdict** (changed 2026-11-12,
PyAutoHeart#340; ruling M2.1 in "M2 rulings — 2026-11-12" below):
`pyauto-heart readiness --dev --repos A,B --json`, with the repos taken
from the task's `repos:` in `PyAutoMind/active.md`
(`consult_vitals_verdict --repos "$(active_task_repos <task>)"`). Only CI
on `main` of the touched repos and their dependants blocks; every other
reason comes back in `shown_reasons` and is listed in the PR body without
blocking. Only **GREEN** passes. **STALE** — in-scope evidence missing,
unfinished, or older than 6 h — **never passes**: re-check, or park. With
**no Heart CLI** (a web session) the one fallback is the *published*
organism-wide feed: GREEN and under 6 h old passes, because it is at least
as strict as any scope; anything else parks. Any other scoped read that
cannot be made (an empty `repos:`, a Heart without the gate, an unknown
repo name) is "unknown" and parks. Until this change the leg
read the whole-organism verdict and let STALE pass; the scoped verdict has
no YELLOW tier, so the YELLOW acknowledgement below (bound to the *exact
reason list* at launch, for that launch only) applies only if a YELLOW
verdict is ever returned. Releases are unaffected — they ask the unscoped
verdict and always require GREEN.

5. **Independent adversary** — **added 2026-08-30, required for a BATCH
launch** (below) and for any run counting toward the multi-repo autonomy
Expand Down Expand Up @@ -655,6 +662,80 @@ row suspends the actor rule — the count goes back to every in-window row, with
doctrine edit citing the row. A `reverted` row still demotes `glance` as the
ruling says.

## M2 rulings — 2026-11-12

Ruled by the human 2026-11-12 at the M1→M2 gate of the autonomous-orchestrators
programme, one ruling per M2 decision sheet; this section is the dated doctrine
record of all six. Each quotes, verbatim, the recommendation the human adopted
from the sheets' index, then names the build issue or the human act it awaits,
and the condition that reverts it. It records the rulings; the doctrine text
each one changes elsewhere in this file is edited by its own build, not here.

**M2.1 Heart branch scope.** *"Yes: enforce library CI for touched repos and
their dependants; show the rest. Feed: 6 h maximum age plus event triggers,
built first. Rule that an over-age feed re-checks or parks, never passes."* A
STALE feed never passes a development ship: over the maximum age the door
re-reads the touched repos' `main` CI at ship time, and an unattended run that
cannot parks. The override row stays, with its reason machine-readable.
Build: PyAutoHeart#340. *Revert condition:* any ship passed by the branch scope
that breaks `main` of a touched repo or a dependant, where the organism-wide RED
would have stopped it — return to the full verdict by dated doctrine edit.

**M2.2 Server-side merge gate.** *"Yes, staged: libraries and tested organs
first, workspaces after a week, Mind after M4.3. Require status checks, not
reviews. `--auto` for notify and glance only. A separate worker identity at
M4."* `judge` stays a human merge; the ban under the corrective-RED path stays.
Awaits a human act: the rulesets are applied by the human with their admin
credential. *Revert condition:* a ruleset that blocks a release, or leaves PRs
pending with no failing check more than twice in a week — set that repo's
ruleset to `disabled` and fix the check list; an auto-merge found to have
passed a never-auto-merge rule withdraws `--auto` by doctrine edit.

**M2.3 Lane fails closed; queue.md is the ranked list.** *"Fail closed in
unattended and cloud sessions only. Keep `queue.md` as a short ranked list,
validated; an empty list stops a shift; sort priority before review-minutes."*
As built: every plan `pyauto-brain batch plan` composes, and every watcher
tick, is unattended, and excludes a backlog draft with no valid `Lane:`, saying
so in the plan and the digest; `batch plan --attended` (a human picking for
their own session) reads an absent Lane as `any`. A brief's named tasks are the
human's own pick and are not gated. Intake refuses to file a new draft whose
lane is neither declared (a `Lane:` header, or the filer's `--lane`) nor
inferred from a resource signal, and says how to declare one. `lifecycle.py check`
fails on a `queue.md` prompt ref that resolves to no draft or active prompt
(`lifecycle.py close` retires a completed task's entry to the footer); an
empty or absent `queue.md` stops an unattended shift's backlog dip (named tasks
still run); below the queue the planner sorts priority, then review-minutes.
Build: PyAutoBrain#614. *Revert condition:* if fail-closed excludes more than a
handful of valid drafts in a week for a missing header, re-run
`bin/lane_backfill.py`; if that does not fix it, return to `any` for attended
filing. If `queue.md` goes two weeks without an edit, replace it with a
per-draft rank header set in a weekly review.

**M2.4 Release builds the rehearsed SHAs.** *"Yes: release the rehearsed
commits even if `main` moved; move the Colab bump off `main`."* The release log
prints the rehearsed commit, the released commit and `identical`. Build:
PyAutoHands#337. *Revert condition:* a release whose tag does not match the
rehearsed commit, or a Colab notebook that installs the wrong version because
the bump is off `main` — return to `ref: main` plus the freeze flag until fixed.

**M2.5 Always-apply rules.** *"Split the safety rules into a short file
imported by the home `CLAUDE.md`; set a size budget for the memory index
(21.8 KB today)."*
Awaits a human act: these are the human's home-folder files — a session may
draft the edits, the human applies them. *Revert condition:* if a new session's
loaded-file list does not show the rules file, or sessions lose the routing
they need, restore the previous files and fall back to importing the whole
workspace guidance file from the home `CLAUDE.md`.

**Quarantine (side ruling).** *"Yes: one retry; quarantine needs a bug task,
expires in 7 days, at most 3, shows YELLOW."* The nightly may retry a failing
script once. A script may be quarantined only with a filed bug task, for at
most 7 days, at most 3 entries at once, never a unit test or an install check;
while any entry is live the release shows Heart YELLOW and the digest lists
them. Build: to build. *Revert condition:* a release that ships with a
quarantined script hiding a real user-facing break — quarantine returns to
human-only.

## Shift briefs and unattended `glance` — 2026-11-03

Approved by the human 2026-11-03 as the rulings of the autonomous-orchestrators
Expand Down
4 changes: 3 additions & 1 deletion ORGANISM.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ Brain → Heart (gate) → Build (execute)

The Brain asks `pyauto-heart readiness --json`, reasons over the verdict, and
only on **GREEN** triggers Build. Heart never triggers Build; Build never
re-derives a decision the Brain already made.
re-derives a decision the Brain already made. A development ship asks the
scoped gate instead, `pyauto-heart readiness --dev --repos A,B --json` (the
branch's repos and their dependants; STALE never passes — PyAutoHeart#340).

## Agents: conductors and faculties

Expand Down
155 changes: 139 additions & 16 deletions agents/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,48 @@ _agents_dir() {
# gate); release-grade work uses this, ordinary build work does not.
# --profile P evaluate under a readiness evidence profile (e.g. `release-ci`
# for the scheduled-nightly gate — heart/readiness.py "Profiles").
# --repos A,B the DEVELOPMENT-SHIP gate (PyAutoHeart#340, AUTONOMY.md leg 4):
# `pyauto-heart readiness --dev --repos A,B --json`, scoped to the
# repos the branch touches and their dependants, with a 6 h
# evidence age. Its verdict is green | red | stale, and only
# green passes. Take the repos from the task's `repos:` in
# PyAutoMind/active.md (`active_task_repos`). Release callers
# (release conductor, nightly, pre_build) never pass this.
# `--repos ""` (no scope) is "unknown", never an unscoped read.
# Without a Heart CLI that has the gate (a web session), the
# one safe fallback: the PUBLISHED organism-wide feed, GREEN
# and under 6 h old (`bin/heart_feed.py`), passes as "green" —
# it is at least as strict as the scoped verdict. Anything
# else is "unknown".
#
# Echoes one of: green | yellow | red | unknown. Never fails the caller — an
# unresolvable/again-unknown verdict is reported as "unknown" (treated as YELLOW
# by callers), never silently as green.
# Echoes one of: green | yellow | red | stale | unknown. Never fails the caller —
# an unresolvable/again-unknown verdict is reported as "unknown" (treated as
# YELLOW by callers, and as a park by the dev-ship gate), never silently as green.
consult_vitals_verdict() {
local refresh=0 profile=""
local refresh=0 profile="" repos="" scoped=0
while [[ $# -gt 0 ]]; do
case "$1" in
--refresh) refresh=1; shift ;;
--profile) profile="$2"; shift 2 ;;
--profile=*) profile="${1#*=}"; shift ;;
--repos) scoped=1; repos="${2:-}"; shift; shift || true ;;
--repos=*) scoped=1; repos="${1#*=}"; shift ;;
*) shift ;;
esac
done
# A scope was asked for but is empty (a task with no `repos:` block): there
# is nothing to scope to, and an unscoped read would answer a different
# question. Unknown parks.
if [[ "$scoped" -eq 1 && -z "${repos//[ ,]/}" ]]; then
echo "unknown"
return 0
fi
# No Heart CLI here (a web session): the scoped gate cannot be asked, so
# the published-feed fallback is the only answer.
if [[ "$scoped" -eq 1 ]] && ! resolve_heart >/dev/null 2>&1; then
_published_green_fallback
return 0
fi
local vitals
vitals="$(_agents_dir)/faculties/vitals/vitals.sh"
if [[ ! -f "$vitals" ]]; then
Expand All @@ -143,20 +171,52 @@ consult_vitals_verdict() {
# `set -o pipefail`, under which a non-zero exit from the (possibly
# Heart-less) vitals faculty would otherwise double-fire a fallback. The python
# below always prints exactly one token, even on empty/garbage input.
local args=(readiness --json)
[[ -n "$profile" ]] && args+=(--profile "$profile")
local args
args=($(_vitals_readiness_args "$profile" "$repos"))
local out
out="$(bash "$vitals" "${args[@]}" 2>/dev/null | python3 -c '
import json, sys
# A scoped read must come back as Heart's dev-ship verdict: a faculty with no
# Heart CLI answers from the published, organism-wide board, which cannot
# judge the scope — that is "unknown" (park), never a pass.
out="$(bash "$vitals" "${args[@]}" 2>/dev/null | SCOPED="$scoped" python3 -c '
import json, os, sys
try:
v = json.load(sys.stdin).get("verdict", "unknown")
print(v or "unknown")
d = json.load(sys.stdin)
if os.environ.get("SCOPED") == "1" and d.get("gate") != "dev-ship":
print("unknown")
else:
print(d.get("verdict", "unknown") or "unknown")
except Exception:
print("unknown")
' 2>/dev/null)"
printf '%s\n' "${out:-unknown}"
}

# _published_green_fallback — the dev-ship gate's one fallback when there is
# no Heart CLI to ask (a web session; a Heart that answers but errors is
# "unknown", never this fallback): the PUBLISHED
# organism-wide feed, read by bin/heart_feed.py, which already applies the 6 h
# maximum age. GREEN there means every repo is green, which is at least as
# strict as any scope, so it echoes "green"; anything else (an older, undated,
# non-green or unpublished feed) echoes "unknown", which parks.
_published_green_fallback() {
local feed
feed="$(cd "$(_agents_dir)/.." && pwd)/bin/heart_feed.py"
[[ -f "$feed" ]] || { echo "unknown"; return 0; }
# Captured, not piped out: heart_feed exits non-zero on any non-green
# status, which under a caller's pipefail must not add a second token.
local out
out="$(python3 "$feed" --json 2>/dev/null | python3 -c '
import json, sys
try:
s = json.load(sys.stdin)
ok = s.get("source") == "published" and s.get("status") == "green" and s.get("pass") is True
print("green" if ok else "unknown")
except Exception:
print("unknown")
' 2>/dev/null)"
[[ "$out" == "green" ]] && echo "green" || echo "unknown"
}

# Back-compat alias for the pre-rename name (faculty: health -> vitals).
consult_health_agent_verdict() { consult_vitals_verdict "$@"; }

Expand All @@ -165,27 +225,90 @@ consult_health_agent_verdict() { consult_vitals_verdict "$@"; }
# authorize proceeding despite specific, named RED reasons. Reads the SAME
# read-only faculty as consult_vitals_verdict — Heart's verdict is never
# mutated; the override is a Brain-level, recorded decision.
#
# `--repos A,B` reads the scoped dev-ship verdict instead (see
# consult_vitals_verdict); `--field stale_reasons|shown_reasons` prints that
# list of it instead of `red_reasons` (the PR body lists the shown reasons).
consult_vitals_red_reasons() {
local profile=""
local profile="" repos="" field="red_reasons" scoped=0
while [[ $# -gt 0 ]]; do
case "$1" in
--profile) profile="$2"; shift 2 ;;
--profile=*) profile="${1#*=}"; shift ;;
--repos) scoped=1; repos="${2:-}"; shift; shift || true ;;
--repos=*) scoped=1; repos="${1#*=}"; shift ;;
--field) field="$2"; shift 2 ;;
--field=*) field="${1#*=}"; shift ;;
*) shift ;;
esac
done
# An empty scope reads nothing (never the unscoped verdict's reasons).
[[ "$scoped" -eq 1 && -z "${repos//[ ,]/}" ]] && return 0
local vitals
vitals="$(_agents_dir)/faculties/vitals/vitals.sh"
[[ -f "$vitals" ]] || return 0
local args=(readiness --json)
[[ -n "$profile" ]] && args+=(--profile "$profile")
bash "$vitals" "${args[@]}" 2>/dev/null | python3 -c '
import json, sys
local args
args=($(_vitals_readiness_args "$profile" "$repos"))
bash "$vitals" "${args[@]}" 2>/dev/null | FIELD="$field" python3 -c '
import json, os, sys
try:
for r in (json.load(sys.stdin).get("red_reasons") or []):
for r in (json.load(sys.stdin).get(os.environ["FIELD"]) or []):
if str(r).strip():
print(str(r).strip())
except Exception:
pass
' 2>/dev/null
}

# _vitals_readiness_args <profile> <repos> — the `pyauto-heart` argument words
# for one readiness read: the release verdict (optionally under a profile), or,
# with repos, the scoped development-ship gate. Repo names carry no spaces.
_vitals_readiness_args() {
local profile="$1" repos="$2"
if [[ -n "$repos" ]]; then
echo "readiness --dev --repos $repos --json"
elif [[ -n "$profile" ]]; then
echo "readiness --json --profile $profile"
else
echo "readiness --json"
fi
}

# active_task_repos <task-slug> [active.md] — the repos a task's branch
# touches, comma-joined, from its `- repos:` block in PyAutoMind/active.md
# (` - <Repo>: <branch>` lines). This is the dev-ship gate's `--repos`.
# Prints nothing (exit 1) when the task or its repos are not found — the caller
# must then stop, never ship against an unscoped or empty scope.
active_task_repos() {
local slug="$1" ledger="${2:-}"
if [[ -z "$ledger" ]]; then
local mind; mind="$(resolve_mind 2>/dev/null)" || return 1
ledger="$mind/active.md"
fi
[[ -f "$ledger" ]] || return 1
SLUG="$slug" python3 - "$ledger" <<'PY'
import os, re, sys
slug, repos, inside, in_repos = os.environ["SLUG"].strip(), [], False, False
for line in open(sys.argv[1], encoding="utf-8", errors="replace"):
line = line.rstrip("\n")
if line.startswith("## "):
inside = line[3:].strip() == slug
in_repos = False
continue
if not inside:
continue
if re.match(r"^-\s+repos:\s*$", line):
in_repos = True
continue
if in_repos:
m = re.match(r"^\s+-\s+([^:\s]+)\s*(?::.*)?$", line)
if m:
if m.group(1) not in repos:
repos.append(m.group(1))
continue
in_repos = False
if not repos:
sys.exit(1)
print(",".join(repos))
PY
}
Loading
Loading