Skip to content

Commit 76b6703

Browse files
authored
Merge pull request #35 from PyAutoLabs/feature/autonomy-contract
docs: the autonomy contract — AUTONOMY.md, model-tier doctrine
2 parents 396d1e6 + f2a474e commit 76b6703

3 files changed

Lines changed: 166 additions & 21 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ consult faculties; faculties read their sensor organ; a conductor never
4444
consults another conductor — if it wants one's opinion, that opinion should be
4545
a faculty. The Build Agent is the reusable template for this pattern.
4646

47+
How much human checkpointing a workflow run needs is defined once in
48+
[`AUTONOMY.md`](AUTONOMY.md) — the autonomy contract mapping each Mind-prompt
49+
`Autonomy:` level to behaviour at every checkpoint.
50+
4751
## Specialist reasoning agents
4852

4953
Agents live in **two tiers** under `agents/`, distinguished by one question —

AUTONOMY.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# The autonomy contract
2+
3+
The **one canonical page** for how much human checkpointing a workflow run
4+
needs. Mind prompts carry `Autonomy: safe | supervised | human-required` in
5+
their header (written at conception by the Intake Agent via the sizing
6+
faculty — `PyAutoMind/README.md` "Prompt file format"); this page defines what
7+
those levels *do* at each checkpoint. Every workflow skill links here instead
8+
of restating checkpoint rules — if you are editing autonomy prose anywhere
9+
else, stop and edit this file.
10+
11+
Levels are consumed **only as defined here**. A level is an input to a gate,
12+
never a bypass of one.
13+
14+
## The checkpoints
15+
16+
Where the dev workflow stops for a human today:
17+
18+
| # | Checkpoint | Lives in |
19+
|---|------------|----------|
20+
| 1 | **Plan approval** — present the plan, wait for explicit approval before any edit | `start_dev` (Plan Mode) |
21+
| 2 | **Ship PR sign-off** — review of `## API Changes` / `## Scripts Changed` before commit/push/PR | `ship_library` / `ship_workspace` |
22+
| 3 | **Heart YELLOW acknowledgement** — warnings surfaced, proceed only on explicit go-ahead | ship gate (`skills/WORKFLOW.md` "Heart readiness gate") |
23+
| 4 | **Merge / issue close** — offered after shipping, never automatic | post-ship |
24+
| 5 | **Version ask** — the minor-version choice | `pre_build` |
25+
| 6 | **Post-merge cleanup confirmation** — worktree removal, branch deletion, registry moves | `ship_*` cleanup |
26+
27+
## Levels × checkpoints
28+
29+
| Checkpoint | `safe` | `supervised` | `human-required` |
30+
|------------|--------|--------------|------------------|
31+
| Plan approval | write plan to the issue, proceed | write plan to the issue, proceed | present + wait |
32+
| Ship PR sign-off | proceed through the autonomous-ship gate; end at PR-open | park (`awaiting-input`), question to the issue, continue elsewhere | present + wait |
33+
| Heart YELLOW | park — human checkpoint at **every** level | park | present + wait |
34+
| Heart RED | stop, report | stop, report | stop, report |
35+
| Merge / close | human, always | human, always | human, always |
36+
| Version ask | n/a — release is always `human-required` | n/a | ask |
37+
| Cleanup | proceed + log | proceed + log | confirm |
38+
39+
The difference between `safe` and `supervised` is the ship step and judgment
40+
gates: `safe` runs end-to-end to an open PR; `supervised` proceeds wherever the
41+
path is mechanical but converts each judgment gate into a batched question on
42+
the issue and moves on (**checkpoint-and-continue** — the question is written
43+
with enough context to answer cold, the task parks as `awaiting-input` in
44+
`active.md`, and the session advances to the next independent step or task
45+
rather than blocking).
46+
47+
## Per-work-type caps
48+
49+
A prompt's header never exceeds its work-type cap. The **effective level** is
50+
`min(header, cap)`; a missing header means `human-required`.
51+
52+
| Work-type | Cap | Why |
53+
|-----------|-----|-----|
54+
| `refactor`, `test`, `maintenance` | `safe` | behaviour-preserving by definition; tests + review are a near-complete gate |
55+
| `feature`, `bug`, `docs` | `supervised` | until the calibration log justifies raising |
56+
| `research`, `experiment` | `supervised` | output is judgment-shaped |
57+
| `release` | `human-required` | always; no autonomy level ships a release |
58+
59+
Raising a cap is a doctrine edit to this page and must cite calibration-log
60+
evidence.
61+
62+
## Activation
63+
64+
- Levels bind **only** when the human launches with an explicit `--auto`.
65+
Default invocations behave exactly as before this page existed —
66+
present-and-wait at every checkpoint.
67+
- Opt-in per invocation, never ambient: no config flag, no environment
68+
variable, no "remembered" mode.
69+
70+
## The autonomous-ship gate
71+
72+
An unattended ship (checkpoint 2 at `safe`) requires **all four**, no
73+
substitutions:
74+
75+
1. worktree pytest on the affected repos (full suite),
76+
2. the curated smoke-test subset,
77+
3. review-faculty verdict **CLEAN**,
78+
4. Heart **GREEN**.
79+
80+
The gate's audit and precise composition are `PyAutoMind/feature/autonomy/`
81+
task 3; the review faculty is task 2. **Until both land, no run ships
82+
unattended**`--auto` ends at ship sign-off regardless of level. A failed
83+
gate downgrades the run to a human checkpoint: state written to the issue,
84+
nothing force-shipped.
85+
86+
## Calibration log
87+
88+
`PyAutoMind/autonomy_log.md` — append-only. Every `--auto` run appends a row
89+
at PR-open (or on parking):
90+
91+
```markdown
92+
| date | task | effective level | gates (tests/smoke/review/heart) | outcome |
93+
```
94+
95+
Outcome ∈ `merged-unchanged` / `amended` / `rejected` / `parked`. This is the
96+
evidence base for raising or lowering caps — autonomy grows by demonstrated
97+
calibration, not by optimism.
98+
99+
## Hard invariants (every level, no exceptions)
100+
101+
- **Merge and issue-close are human acts.** An explicit future flag may extend
102+
autonomy to merge; it does not exist and must not be assumed.
103+
- **Autonomous runs end at PR-open**, with the PR body carrying the plan, the
104+
review verdict, test/smoke counts, and a validation checklist.
105+
- **Never modify code to make tests or smoke tests pass.**
106+
- **Heart YELLOW/RED is never acknowledged autonomously.**
107+
- **Never rewrite history** (`AGENTS.md` rules apply verbatim to autonomous
108+
runs).
109+
- The `Autonomy:` header is a model's own estimate. The caps, the explicit
110+
`--auto` launch, and the calibration log are what make consuming it
111+
defensible — none of the three is optional.
112+
113+
## Consumers
114+
115+
Today: **none** — this page is doctrine ahead of implementation, by design.
116+
Consumption lands with the `PyAutoMind/feature/autonomy/` series: task 4
117+
(`--auto` through `start_dev → ship_*`), task 5 (checkpoint-and-continue),
118+
task 7 (queue runner). Skills must link here rather than copying the tables.

skills/WORKFLOW.md

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ directly; it asks the vitals faculty, and only the vitals faculty talks to the H
4040
organ. The same applies when the dev workflow consults the vitals faculty for its
4141
ship gate.
4242

43+
## Autonomy (how much human checkpointing)
44+
45+
The human checkpoints across these skills — plan approval, ship PR sign-off,
46+
Heart YELLOW acknowledgement, merge/close, the `pre_build` version ask,
47+
post-merge cleanup — are governed by **the autonomy contract**,
48+
[`../AUTONOMY.md`](../AUTONOMY.md): what each Mind-prompt `Autonomy:` level
49+
(`safe`/`supervised`/`human-required`) does at each checkpoint, the
50+
per-work-type caps, and the hard invariants (merge is always human; autonomous
51+
runs end at PR-open). Levels bind **only** under an explicit `--auto` launch;
52+
default runs present-and-wait at every checkpoint, exactly as the steps below
53+
describe. Do not restate checkpoint rules in a skill body — link the contract.
54+
4355
## Brain agent entry points
4456

4557
Reasoning is delegated to PyAutoBrain agents (`PyAutoBrain/AGENTS.md` is authoritative):
@@ -59,13 +71,20 @@ When `pyauto-brain` is not on `PATH` and no PyAutoBrain checkout is present
5971
(e.g. a GitHub-only session), perform the same reasoning inline following this
6072
file and `PyAutoBrain/AGENTS.md`, and note that the agent was emulated.
6173

62-
## Model delegation (Opus plans, Sonnet executes)
74+
## Model delegation (judgment tier plans, execution tier ships)
75+
76+
The workflow skills split work across **model tiers**, not named models — the
77+
doctrine survives model access changing:
78+
79+
- **Judgment tier** — the strongest model available to the session (currently
80+
**Fable 5**; previously, and as fallback, **Opus**). Planning, orchestration,
81+
risk judgment, anything user-facing.
82+
- **Execution tier** — a fast, cheap model (currently **Sonnet**) for
83+
mechanical shell/git phases, delegated as subagents (`Agent` tool,
84+
`model: "sonnet"`).
6385

64-
The workflow skills follow a **"plan in Opus, execute in Sonnet"** split: the main
65-
session stays on Opus for planning, judgment and orchestration; mechanical
66-
shell/git phases are delegated to Sonnet subagents (`Agent` tool,
67-
`model: "sonnet"`). This keeps judgement in the stronger model while moving bulk
68-
execution to the faster, cheaper one — no manual model toggling.
86+
The main session stays on the judgment tier; bulk execution moves to the
87+
execution tier — no manual model toggling.
6988

7089
**Delegated (mechanical phase only):**
7190

@@ -74,7 +93,7 @@ execution to the faster, cheaper one — no manual model toggling.
7493
- `pre_build` — step 2 (format, generate, version bump, stage, commit, push,
7594
dispatch workflow).
7695

77-
**Stays in Opus:** planning (`start_dev`), environment setup
96+
**Stays in the judgment tier:** planning (`start_dev`), environment setup
7897
(`start_library`/`start_workspace`), release triage (`review_release`);
7998
identifying affected repos, drafting the commit message and full PR body
8099
(`## API Changes` / `## Scripts Changed`), workspace-impact analysis, the
@@ -84,31 +103,32 @@ asking for the minor version, printing the summary.
84103

85104
**Subagent prompt contract (all delegated calls):**
86105

87-
- **Inputs Opus passes:** worktree path / `$WT_ROOT`, repo list, pre-drafted
88-
commit message, pre-drafted PR body (paste verbatim via HEREDOC — never
89-
rewrite), relevant URLs (library PR, issue), target branch, labels.
106+
- **Inputs the judgment tier passes:** worktree path / `$WT_ROOT`, repo list,
107+
pre-drafted commit message, pre-drafted PR body (paste verbatim via HEREDOC —
108+
never rewrite), relevant URLs (library PR, issue), target branch, labels.
90109
- **Subagent's job:** run the named shell steps exactly. `source activate.sh`
91110
before `pytest` / `smoke_test`. Verify the branch is `feature/<task-name>`
92111
before committing — never auto-switch branches. **Never modify code to make
93112
tests or smoke tests pass.** On failure, stop and return the failure verbatim
94113
(failing test names + traceback tail, or the shell error).
95114
- **Subagent returns:** one line per repo — test/smoke pass-fail counts, commit
96115
SHA, PR URL, cross-reference/dispatch confirmations.
97-
- **Opus after return:** interpret failures, decide routing, update registries,
98-
talk to the user.
116+
- **Judgment tier after return:** interpret failures, decide routing, update
117+
registries, talk to the user.
99118

100119
**Tutorial-prose split** (separate from skill delegation — depends on what the
101120
reader is there to learn):
102121

103-
- **Opus** for narrative science-teaching scripts where the docstrings/comments
104-
are the product: tutorials in `autofit_workspace`, `autogalaxy_workspace`,
105-
`autolens_workspace` (`overview_*`, `start_here.py`, `howto*`). Sonnet drifts
106-
to generic textbook phrasing and misses domain framing here.
107-
- **Sonnet** for code-heavy, doc-light scripts where comments are short
122+
- **Judgment tier** for narrative science-teaching scripts where the
123+
docstrings/comments are the product: tutorials in `autofit_workspace`,
124+
`autogalaxy_workspace`, `autolens_workspace` (`overview_*`, `start_here.py`,
125+
`howto*`). Execution-tier models drift to generic textbook phrasing and miss
126+
domain framing here.
127+
- **Execution tier** for code-heavy, doc-light scripts where comments are short
108128
API-usage notes: `*_workspace_test`, `euclid_strong_lens_modeling_pipeline`
109129
glue, and developer/regression/smoke/parity scripts.
110130
- Heuristic: *"is the reader here to learn science, or to exercise code?"*
111-
Science → Opus. Code → Sonnet.
131+
Science → judgment tier. Code → execution tier.
112132

113133
## Consult Memory before substantial planning
114134

@@ -127,7 +147,9 @@ pyauto-heart readiness --json # authoritative GREEN / YELLOW / RED verdict
127147
```
128148

129149
- **GREEN** → proceed to execution.
130-
- **YELLOW** → surface the warnings; proceed only with explicit user acknowledgement.
150+
- **YELLOW** → surface the warnings; proceed only with explicit user
151+
acknowledgement (a human checkpoint at **every** autonomy level —
152+
[`../AUTONOMY.md`](../AUTONOMY.md)).
131153
- **RED** → stop; report what failed. Do not ship.
132154

133155
Tests/smoke runs that feed the verdict are Heart's domain — invoke them through
@@ -138,11 +160,12 @@ the vitals faculty rather than re-deriving pass/fail criteria in the skill.
138160
- `/name` references mean "use that skill"; a harness without slash commands
139161
follows the same body file directly.
140162
- "Plan Mode" means: present the plan and wait for explicit user approval
141-
before any file edit.
163+
before any file edit (checkpoint 1 of [`../AUTONOMY.md`](../AUTONOMY.md);
164+
under an explicit `--auto` launch the contract's level table applies).
142165
- If the user gives a development task with **no** PyAutoMind prompt path,
143166
first write a concise prompt under the right `<work-type>/<target>/` folder
144167
(original request verbatim), then continue with that path.
145-
- Where a body delegates mechanical execution to a Sonnet subagent, a harness
168+
- Where a body delegates mechanical execution to an execution-tier subagent, a harness
146169
without subagents performs the same steps directly, preserving the
147170
judgment/mechanical split above.
148171

0 commit comments

Comments
 (0)