Skip to content

feat: shift launch preflight — issue, login probe, brief discovery (M3.6a) #659

Closed

Description

@Jammy2211

Overview

Milestone task M3.6a of the autonomous-orchestrators epic (PyAutoBrain#574 programme). Shift 2026-11-16-pm lost launch time to four things the launch could have checked: no shift issue, an expired CLI login read as "blocked on a person", the watcher reading a stale brief from its env file, and a watcher that never stops. This adds those checks. Build first, in chat: a shift never changes its own watcher.

Plan

  • batch brief --new --out creates the shift issue on PyAutoMind and writes issue:; brief --check refuses a live brief without it.
  • A login probe with no model call (claude auth status --json: loggedIn, loginExpiresAt), in brief --check (also refusing a login that expires before review-at) and the watcher's first tick; an expired login is its own login-expired event and holds spawning.
  • The watcher finds the one open brief on Mind origin/main itself (dispatched <= now < review-at); two open briefs means idle with that reason; PYAUTO_SHIFT_BRIEF / --brief become an override honoured only inside its window.
  • After review-at + 45 min (digest posted) the watcher stops ticking and renewing leases.
  • Two dated AUTONOMY amendments (approved by the human 2026-11-17): the login probe on the watcher's surface, and brief --new's one gh issue create as an exception to "The Brain reads no network".
  • Tier: judge — merge mode: human /prm
Detailed implementation plan

Affected Repositories

  • PyAutoBrain (primary)
  • PyAutoMind

Branch Survey

Repository Current Branch Dirty?
PyAutoBrain (canonical) main, 6 behind origin untracked .worktrees/ only
PyAutoMind (canonical) main, 72 behind origin another session's uncommitted batches/2026-11-16-pm.md (left alone)

Suggested branch: feature/shift-launch-preflight (worktree ~/Code/PyAutoLabs-wt/shift-launch-preflight/). Runs in parallel with M3.6d and M3.6e (file-disjoint apart from adjacent hunks; human approved the repo-claim coordination).

Implementation Steps

  1. New agents/conductors/batch/_login.py: probe(run=None) → ok | expired | unknown | skipped (PYAUTO_LOGIN_PROBE=off), from claude auth status --json (loggedIn, loginExpiresAt), also matching "Login reached its time limit"; EXPIRED_LINE = "CLI login expired: run \claude /login`"`.
  2. _brief.py: LATE_WINDOW_S = 45*60, launch_errors(top, brief) (non-shadow brief without an issue URL). check() unchanged (the watcher calls it).
  3. _batch.py: --issue URL; create_shift_issue() (one gh issue create, URL parsed); new_brief(..., issue=) writes - issue:; the --new --out branch creates the issue unless --issue/PYAUTO_BRIEF_ISSUE=off, reuses an existing issue:, writes nothing if gh fails; --check appends launch_errors and the probe (refuse on expired or on expiry before review-at; res["login"] in JSON).
  4. _events.py: kind login-expired, deriver after _impaired.
  5. _orchestrator.py (only): imports; new _late_closed after brief_open; guard at the top of _tick's not-open branch; _tick_body login hold before spawning (_login_hold, re-probe when a worker shows blocked); new shift_briefs / find_briefs / watch before main (git ls-tree/show on origin/main, no fetch; "checkout behind" idle when the pushed brief is missing from the tree); main makes --brief optional. Not touched: _reap, close-out code, finish_shift, late_sweep.
  6. bin/systemd/pyauto-orchestrator.service drops --brief ${PYAUTO_SHIFT_BRIEF}; _watch.LATE_WINDOW_S from _brief; tests/conftest.py autouse PYAUTO_LOGIN_PROBE=off, PYAUTO_BRIEF_ISSUE=off.
  7. Docs: AUTONOMY.md "Shift brief = launch" + the two dated amendments; agents/conductors/batch/AGENTS.md; skills/batch/batch.md launch step and reference.md.
  8. Existing tests updated: test_batch_brief_goals.py, test_premise_check.py BRIEF, test_orchestrator_events.py _every_kind_results.
  9. PyAutoMind PR: batches/AGENTS.md "Shift brief" (issue required, only a pushed brief opens, no two open, watcher ends at review-at + 45 min); policy/shift_watcher.md (discovery, probe, end).

Witness mapping

  1. tests/test_batch_brief.py::test_new_creates_one_shift_issue_and_writes_it
  2. ::test_check_refuses_a_live_brief_without_issue
  3. ::test_check_refuses_on_expired_login + tests/test_orchestrator_preflight.py::test_first_tick_logs_login_expired_not_blocked
  4. ::test_watch_ticks_the_one_open_brief_on_origin + ::test_two_open_briefs_idle
  5. ::test_after_late_window_no_tick_and_lease_mtime_unchanged

Key Files

  • agents/conductors/batch/_orchestrator.py, _batch.py, _brief.py, _events.py, new _login.py
  • bin/systemd/pyauto-orchestrator.service, tests/conftest.py, AUTONOMY.md

Original Prompt

Click to expand starting prompt

M3.6a Shift launch preflight: shift issue, login probe, the watcher finds the open brief

Type: feature
Target: PyAutoBrain
Repos:

  • PyAutoBrain
  • PyAutoMind
    Difficulty: medium
    Autonomy: supervised
    Priority: high
    Status: draft
    Filed: 2026-11-17
    Epic: autonomous-orchestrators
    Phase: 10
    Consequence: judge
    Witness: python -m pytest tests/test_batch_brief.py tests/test_orchestrator_*.py -q passes with new tests that fail on today's main: (1) batch brief --new with a fake gh creates one PyAutoMind issue and writes its URL as issue:; (2) brief --check on a live brief without issue: exits non-zero and names the key; (3) a fake claude printing "Login reached its time limit" makes brief --check fail and makes the first tick log a login-expired event, not "blocked on a person"; (4) with two brief fixtures on a fake Mind origin/main the watcher ticks the one whose dispatched: has passed and review-at: has not, and with two open briefs it idles and logs "two open briefs"; (5) a tick after review-at: + 45 min exits without ticking work and leaves every lease file's mtime unchanged
    Lane: local-dev
    Unattended: never

Why

Shift 2026-11-16-pm lost time at launch to four things the launch could have checked.

  • No shift issue. The kick-off chat grepped _brief.py for issue:, found nothing and
    dropped it. brief --check passed. So there was no live status comment, no steering by
    comment, no /cap, and the digest and the late-arrival correction were never posted
    (digest.posted: "the brief names no issue:").
  • Expired CLI login. Both first workers stopped at 17:54:48Z and restarted at 17:56:36Z
    after the human's /login and a message from the kick-off chat. The watcher called it
    "blocked on a person".
  • Watcher on the old brief. The 17:49Z tick read "idle: review-at 2026-11-14T19:35Z has
    passed", because PYAUTO_SHIFT_BRIEF in the env file still named the 14 Nov brief. The
    human edited the env file and the chat fast-forwarded the shared Mind checkout. 5 minutes
    lost.
  • The watcher never stops. On 2026-11-17 it was still ticking every 3 minutes and still
    renewing the lease on the question the human had answered.

What

  1. batch brief --new creates the shift issue on PyAutoMind and writes issue: into the
    brief. brief --check refuses a live brief (not shadow: yes) without issue:.
  2. A login probe: brief --check and the first tick run a cheap claude call and refuse or
    pause with their own event wording ("CLI login expired: run claude /login"), distinct
    from "blocked on a person".
  3. The watcher finds the brief itself. It reads batches/*.md on Mind origin/main and takes
    the one brief whose dispatched: has passed and whose review-at: has not. Two open
    briefs means it idles and says so. Only a pushed brief counts, so "pushing the brief is the
    launch" keeps its meaning. PYAUTO_SHIFT_BRIEF becomes an override, not the source.
  4. Once the late window closes (review-at: + 45 min) the watcher stops ticking the slot and
    renewing its leases.

Out of scope

  • The watcher reading the shared Mind checkout at all: that is M4.3 and the infrastructure
    review.
  • Worker SSH keys and the worker environment (infrastructure review).
  • Raising caps by comment (/cap already exists; it needs the issue this task creates).

Activity

  1. Jammy2211 commented on Nov 17, 2026

    @Jammy2211
    ContributorAuthor

    Library PRs created

    Built test-first (new tests fail on origin/main, pass on the branch), independently reviewed by Fable 5.2 (author Opus 5.5): FINDINGS → fixed → CLEAN. Workspace impact: none (organ-only change). Merge: human /prm. Suggested order across M3.6: M3.6d (#660, Mind PR first), then M3.6a (#659), then M3.6e (#661, which needs a one-line import resolution in _orchestrator.py after M3.6a: keep both imports).

    Heart RED override (development only), recorded

  2. Jammy2211 commented on Nov 17, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    Merged by the human's /prm (2026-11-17): PyAutoMind#582, PyAutoBrain#664 (after merging main into the branch to keep both _login and _merge_slots imports; full Brain suite and CI green on the merged head). #582's cancelled Spawn Drift check (concurrency queue) was re-run on the human's word and passed. The Heart RED development override covered shipping only; the merge was this separate human command.

    Launch preflight: brief --new creates the shift issue and --check refuses a live brief without one; claude auth status login probe (no model call) with a login-expired event; the watcher finds the one open brief on Mind origin/main and stops after the late window once nothing is owed.

    Close-out: completion record in PyAutoMind complete/2026/11/, active.md row released, dashboard regenerated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions