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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install (pytest + PyYAML — the whole dependency set)
run: pip install pytest PyYAML
run: pip install pytest PyYAML PyJWT cryptography
- name: Run tests
working-directory: PyAutoBrain
run: pytest tests/ -q
Expand Down
14 changes: 9 additions & 5 deletions AUTONOMY.md
Original file line number Diff line number Diff line change
Expand Up @@ -879,15 +879,19 @@ is never retried. The watcher also reads `gh pr view --json
state,mergedAt,mergedBy` for the PRs its own workers named — the close-out's
merge truth (#603) and, once at `review-at:`, the digest's `merges` (#610).
It also makes one read-only `gh api user` per shift, under the posting token,
to warn when it equals the mention login (#611).
to warn when it equals the mention login (#611) — as the App, one `GET /app`
with its JWT instead, naming it `<slug>[bot]` (#630).
The revert condition now reads: one network call outside these, or a comment
beyond these (a second digest, a second mention for the same worker and
state, a second correction), retires the watcher to fake mode. **Posting identity, ruled
by the human 2026-11-12 (PyAutoLabs/PyAutoBrain#611):** the watcher's GitHub
writes use a separate bot or machine account's token, set by the human as
`PYAUTO_SHIFT_GH_TOKEN` (fine-grained, PyAutoMind issues:write only); until it
is set they post as the human's account and the digest warns that the
mention will not notify.
writes use the watcher's App installation token (PyAutoBrain#630), minted by
one `POST /app/installations/<id>/access_tokens` call on each tick that makes
a watcher GitHub call and held in memory for that tick only. Without the App,
a separate account's static token, `PYAUTO_SHIFT_GH_TOKEN` (fine-grained,
PyAutoMind issues:write only), is the fallback. With neither set, the writes
post as the human's account and the digest warns that the mention will not
notify.

**Amendment — 2026-11-13 (PyAutoBrain#622), authorized by the human.** The
human approved the live shift view as drafted on 2026-11-13: a running shift
Expand Down
54 changes: 45 additions & 9 deletions agents/conductors/batch/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,51 @@ live:` line (`record-key` op, one Mind writer, on a change of state), shown in
the batch box. Doctrine: AUTONOMY.md watcher network surface, amendment
2026-11-13.

**The watcher's GitHub identity (human ruling 2026-11-12, #611).**
`PYAUTO_SHIFT_GH_TOKEN` holds a separate bot or machine account's token,
**fine-grained, PyAutoMind issues:write only**, set by the human in the
timer's environment. It is passed as `GH_TOKEN` to the watcher's own
`gh issue comment` and `gh api user` calls and to nothing else (not to workers).
Unset, comments post as the human's account; once a shift, before the first
mention, `gh api user` names the posting account, and if it is the mentioned
login the digest's `### Workers` warns "mention will not notify: posted as the
mentioned account". With nothing pending, the tick is idle. The worker
**The watcher's GitHub identity (human rulings 2026-11-12, #611, and
2026-11-14, #630).** The watcher posts as its own minimal GitHub App,
`pyautolabs-watcher`, set by the human in the timer's environment
(`~/.config/pyauto/orchestrator.env`) with three variables, all or none:

- `PYAUTO_SHIFT_APP_ID` — the App id;
- `PYAUTO_SHIFT_APP_INSTALLATION_ID` — its installation on PyAutoMind's owner;
- `PYAUTO_SHIFT_APP_KEY` — the path of the App's private key (`.pem`, mode 600).

The App is minimal on purpose: **Issues read/write on PyAutoMind only** —
all the watcher does is comment on, edit its comment on and read the shift
issue. It is **not `pyautolabs-bot`**: that App is a ruleset bypass actor with
org-wide push, and a laptop timer must hold no bypass power. Posting as an App
also means the @mention of the human comes from another account, so it
notifies them. `_app_token.py` signs an RS256 JWT (`iat` now − 60 s, `exp` now
+ 9 min, `iss` the App id; PyJWT, else `openssl dgst -sha256 -sign` with no
shell) and mints an installation token with one `POST
/app/installations/<id>/access_tokens` on the first watcher GitHub call of a
tick, reusing it for the rest of that tick. The token is held **in memory
only** — never written to disk, where a worker running as the same user could
read it; each tick that makes a watcher GitHub call mints its own. The token is
passed as `GH_TOKEN` to the watcher's own `gh` calls and to nothing else:
**every watcher write** (the status comment and its edits, mentions, the digest,
the correction) and the steering read of the shift issue's comments. Two
**reads** deliberately stay under the human's own `gh` auth, because the App
cannot see library repositories: `gh pr view` for the PRs its workers named
(`gh_pr_state`, the close-out's merge truth and the digest's `merges`) and
`gh pr checks` for their CI (`_digest.pr_health`). If minting fails, the tick
carries on but makes none of the App's calls — no write and no steering read,
never under the human's `gh` auth in their place. The reason goes into
`tick.log` (`github_auth`) and the digest ("GitHub writes held"); a held post
costs no try and is retried. A failed mint is not retried for 10 minutes; the
state directory keeps only its time and reason (`app_mint_failure.json`), no
secret. An App
configured in part (one or two variables) is the same failure. Without the
App, `PYAUTO_SHIFT_GH_TOKEN` (a static fine-grained token, PyAutoMind
issues:write only) is the fallback; with neither, comments post as the human's
account. Neither the App variables, the key path, the static token nor a
minted token reaches a worker or close-out (`worker_env`). Once a shift,
before the first mention, the posting account is named — as the App,
`<slug>[bot]` from one `GET /app` with the JWT (`gh api user` does not answer
for an installation token), else `gh api user` — and if it is the mentioned
login (never, as the App) the digest's `### Workers` warns "mention will not
notify: posted as the mentioned account". With nothing pending, the tick is
idle. The worker
prompt also forbids EnterWorktree (its permission prompt stalls an unattended
worker) and requires the `decision-taken` label on any PR carrying a flagged
decision (pilot live shift 1, 2026-11-06).
Expand Down
Loading
Loading