Skip to content

feat: the shift watcher posts as a minimal GitHub App (#630) - #631

Merged
Jammy2211 merged 3 commits into
mainfrom
feature/watcher-app-identity
Nov 14, 2026
Merged

Jammy2211 merged 3 commits into
mainfrom
feature/watcher-app-identity

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Summary

Closes #630. Human decision, 2026-11-14: the watcher posts as its own minimal App, pyautolabs-watcher: Issues read/write and metadata read, on PyAutoMind only. It does not reuse pyautolabs-bot, which is a ruleset bypass actor with org-wide push. The human created and installed the App, and it was verified read-only.

  • _app_token.py: builds a PyJWT RS256 JWT (openssl fallback, no shell), then mints an installation token. The token is kept in memory for one tick only, with nothing on disk. A mint failure backs off for 10 min and records only a time and reason.
  • Fail-closed: when the App is configured but minting fails, every watcher write and the steering read are held, and the human's auth is never used for them. Two reads (gh_pr_state, pr_health) deliberately use the human's auth, because the App cannot read library PRs. The docs say so.
  • worker_env strips the App settings and any token from workers and close-outs.
  • The poster login is <slug>[bot], read from GET /app.
  • AUTONOMY's network-surface paragraph names the App identity, the mint call and GET /app, and keeps the PYAUTO_SHIFT_GH_TOKEN fallback. No rule changes.

Test plan

  • tests/test_orchestrator_app_identity.py: 11 tests, offline. They cover the JWT claims, the openssl fallback, mint and refresh, the failure backoff, no token on disk, workers stripped, and partial config making no call.
  • Brain suite: 1984 passed. The known environmental failure remains.
  • Live read-only checks: a token minted, pyautolabs-watcher[bot], permissions issues:write + metadata:read, PyAutoMind#561 read.
  • Independent security review: FINDINGS (a doc overclaim, a token cache readable by workers, a temp-file race, a None-token path), then fixed, then CLEAN.

Tier: glance. Merge mode: auto-merge on green, with the Heart dev-ship gate.

🤖 Generated with Claude Code

Jammy2211 and others added 3 commits November 14, 2026 10:00
The watcher's own gh calls (status comment and edit, mentions, digest,
correction, steering read) now run as its GitHub App installation token
when PYAUTO_SHIFT_APP_ID, PYAUTO_SHIFT_APP_INSTALLATION_ID and
PYAUTO_SHIFT_APP_KEY are all set: an RS256 JWT (PyJWT, else openssl dgst
with no shell), one POST /app/installations/<id>/access_tokens, cached
with its expires_at in the state dir (mode 600) and re-minted under
10 min from expiry. PYAUTO_SHIFT_GH_TOKEN stays the fallback.

A failed mint (or a part-configured App) holds every GitHub call: never
the human's gh auth in its place. The reason goes into tick.log and the
digest; a held post costs no try; a failed mint backs off 10 min.
worker_env strips the three App variables and any minted token. The
poster login is the App's <slug>[bot] via GET /app with the JWT.

Docs: batch AGENTS.md identity section; AUTONOMY network-surface
paragraph names the App installation token and the mint call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…630 review)

- No on-disk token cache: the installation token is minted on a tick's
  first watcher GitHub call, reused within that tick and held in memory
  only (a worker running as the same user could read a file). A failed
  mint records only {at, error} in app_mint_failure.json (unique temp
  file + rename, no secret) for the 10-minute back-off.
- env() in App mode raises when it holds no token; never returns None.
- AGENTS.md: every watcher write (and the steering read) uses the App;
  gh pr view (gh_pr_state) and gh pr checks (pr_health) stay human-auth
  reads, since the App cannot see library repos. AUTONOMY.md: mint per
  tick, the PYAUTO_SHIFT_GH_TOKEN fallback restored, the dangling
  "until it is set" sentence fixed.
- Tests: in-memory mint once a tick with no file holding the token;
  failure record holds only time and reason; App mode without a token
  raises; the mint-failure tick test asserts no file holds the token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
)

The watcher's runtime (system python3) has both; CI only installed pytest + PyYAML.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 1be4ba0 into main Nov 14, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the feature/watcher-app-identity branch November 14, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: watcher posts as a minimal GitHub App (installation token per tick)

1 participant