Skip to content

feat: shift-end cloud workspace sweep, red blocks unattended merges (M3.7e) - #693

Merged
Jammy2211 merged 3 commits into
mainfrom
feature/shift-end-cloud-sweep
Nov 19, 2026
Merged

Jammy2211 merged 3 commits into
mainfrom
feature/shift-end-cloud-sweep

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Summary

M3.7e of the autonomous-orchestrators epic, the last M3.7 task (closes #692). Ruling S4 (human, 2026-11-19) and the human's plan decisions: /clear-sweep as a new steer command; the one dispatch per shift under the human's own gh login (decision b); the artifact downloads and compare reads approved.

  • Dispatch at close. A shift that merged at least one library, chain or workspace PR (merged at or after its dispatched:) runs gh workflow run workspace-smoke.yml on Heart once at close, early close or review-at, or in the late window when a close-out merged after the close. An exclusive sweep.dispatched marker is claimed before the call; a failed dispatch is reported in the digest and never retried. No force, no --ref; shadow and fake-mode shifts never dispatch.
  • Reading the sweep. One gh run list of the sweep on main a tick. Per run id, once (at most 3 tries, cached in the orchestrator home across shifts): the M3.7d workspace-smoke-shas record and, for a red run, workspace-validation-report. A cancelled run is not a verdict; the run before it counts.
  • Red block. While the latest completed run is red and not cleared, a PR on a repo in a failing workspace's install chain (Heart smoke.workspaces.<name>.chain, plus the workspace repo; sweep_siblings maps the HowTo and test projects) is refused for /prm with workspace sweep red: <run url>, with no session or slot. Anything unmappable blocks every library, chain and workspace repo. Running close-outs get a .sweep-red marker they check just before merging. A run list that has failed continuously for 30 minutes makes PRs wait (not refused) and keeps the shift from closing early.
  • Clearing. A later green run on main, or /clear-sweep on the shift issue (the human's login; clears the latest red run id; carries to later shifts; a newer red run blocks again).
  • Bug draft. One per red run, through the one Mind writer, idempotent on the run id: failing workspaces and scripts, blocked repos, and the suspect PRs from one compare read per affected repo between the last green and the red run's SHAs. It says reverts are draft PRs for the human and bisection runs from chat with workspace-smoke-pinned.yml. Nothing reverts or bisects unattended.
  • Digest. "Workspaces verified through <sha>" per repo from the latest green record; "sweep running: " or "dispatched at , not yet listed"; the red block, refused PRs and the draft path; or the unknown state and the PRs waiting.

API Changes

None to any library. Brain internals: new agents/conductors/batch/_sweep.py; /clear-sweep steer command; config/policy.yaml shift_watcher: gains sweep_repo, sweep_workflow, sweep_siblings. See full details below.

Risks and known gaps

  • The latest green sweep on main (run 44521331980) predates M3.7d and has no SHA record, so until a newer green run exists the digest has no "verified through" line and a red run's draft names no suspect PRs. Tonight's nightly run should provide it.
  • The run list is read before the dispatch on the closing tick, so the shift's own digest usually says "dispatched at , not yet listed"; the next shift or the nightly run reads the result.
  • If the human's gh login cannot dispatch, the digest says so; the nightly covers it.
  • Follow-ups from review round 3 (low, not fixed here): fail_since survives the gap between shifts (now only a wait that one good read releases); the digest's per-PR row does not name the sweep wait (the "Workspace sweep" section does).

Test Plan

  • Tests first: tests/test_shift_end_sweep.py (36 tests, with a trimmed real workspace-validation-report fixture). Round-0 tests failed or errored with the feature absent; each review-round test failed before its fix.
  • Full Brain suite: 2520 passed, 1 skipped.
  • bin/check_skill_line_counts.sh 200 PyAutoBrain (cockpit at 200), tenant firewall, install.sh --check-project-discovery: OK.
  • Independent review (fresh Opus 5.5 session; parsed a real Heart report and checked all 10 cloud projects map): round 1 FINDINGS (2 medium fail-open gaps, 6 low), fixed; round 2 FINDINGS (unknown state refused too early and for the shift, doubled refusal text, untested real config), fixed; round 3 CLEAN.
  • Heart scoped dev-ship verdict for PyAutoBrain: green (after pyauto-heart tick; it read stale while main CI for feat: shift watcher 60 s tick, early close, decision-taken refused at PR-open (M3.7c) #691 was finishing).
  • Smoke: n/a (organism repo).
Full API Changes (for automation & release notes)

Added

  • agents/conductors/batch/_sweep.py — config, dispatch, run list, artifact downloads, chain map, block, /clear-sweep, compare reads, bug draft.
  • Steer command /clear-sweep.
  • config/policy.yaml shift_watcher: sweep_repo, sweep_workflow, sweep_siblings.

Changed Behaviour

  • finish_shift and late_sweep dispatch the sweep (once per shift); _tick_body reads it each tick.
  • _start_closeouts refuses PRs on red-blocked repos and holds them while the sweep state is unknown.
  • early_close_ready stays open while the sweep state is unknown.
  • closeout_template.md checks <task>.sweep-red before merging.
  • Digest gains a "Workspace sweep" section.

🤖 Generated with Claude Code

Jammy2211 and others added 3 commits November 19, 2026 16:19
…ck on red (#692)

Ruling S4 and the red handling (AUTONOMY.md "Shift speed — 2026-11-19"):

- finish_shift dispatches workspace-smoke.yml once (no inputs, marker
  sweep.dispatched) when GitHub confirmed a library or workspace PR merged
  this shift; never in a shadow or fake shift; a failed dispatch is
  reported in the digest and never retried.
- One gh run list a shift tick; each run's artifacts downloaded once per
  run id (at most 3 tries), cached in <home>/sweep/ across shifts.
- A red latest run blocks unattended close-outs on its failing workspaces'
  install chains (Heart config/repos.yaml smoke:) and workspace repos;
  unmapped or unreadable means every library repo. Running close-outs get
  a .sweep-red marker the close-out template checks before merging.
- A later green run or the new /clear-sweep steer command clears it.
- One bug draft per red run through the one Mind writer, with failing
  scripts and suspect PRs from one compare read per affected repo.
- Digest: dispatch state, verified-through SHA per library, red line.
- All sweep calls under the human's gh login (decision b); repo and
  workflow from config/policy.yaml shift_watcher: sweep_*.
- AUTONOMY.md network-surface amendment, batch AGENTS.md, cockpit skill.

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

1. The fallback block (unmapped workspace, unreadable report or Heart
   maps) covers every library, chain and workspace repo, Nerves included.
2. A run list never read, or unread for 30 minutes, blocks the same set:
   "workspace sweep unknown: run list unreadable since <t> → /prm", in
   the digest too.
3. Heart chain repos count as flow repos: their merges dispatch, they get
   a verified-through line and can be the bug draft's target.
4. Failing scripts are named from /<directory>/ on in `file` (else after
   /workspace/); tested on a trimmed real report.
5. A cancelled run is no verdict: the run before it on main counts.
6. late_sweep makes the shift's one dispatch when a close-out merged after
   the close and none was made (same sweep.dispatched marker).
7. A .sweep-red marker the current block does not cover is removed.
8. The bug draft is filed from the latest red run, cleared or not.

Tests default the sweep off (conftest); AUTONOMY.md and batch AGENTS.md
updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1. The unknown state starts 30 minutes after the first failure of the
   current failing streak (fail_since, reset on a good read), so one 502
   after a long gap blocks nothing. Unknown is a wait, not a refusal: PRs
   are held in counters["sweep_waits"] (no session, no slot), re-judged
   each tick, and the shift does not close early while it lasts. A red
   block stays a refusal. Running close-outs still get the marker.
2. The .sweep-red marker holds one complete reason line (red or unknown);
   the close-out refuses with it verbatim, then "→ /prm".
3. A test of the real _sweep_cfg against config/policy.yaml, and {} in
   fake mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 730d065 into main Nov 19, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the feature/shift-end-cloud-sweep branch November 19, 2026 16:56
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: shift-end cloud workspace sweep, red blocks unattended merges (M3.7e)

1 participant