Skip to content

feat: shift event stream, batch watch --stream, /add /cap /kill (M3.4 build A, #644) - #647

Merged
Jammy2211 merged 3 commits into
mainfrom
feature/m34-engine
Nov 16, 2026
Merged

Jammy2211 merged 3 commits into
mainfrom
feature/m34-engine

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Summary

Closes #644, the engine side of the M3.4 chat cockpit. Design: Science/scratch/m3_4_m3_5_design/DESIGN.md §1, §2.3, §3.3. The human's decisions, all as recommended (2026-11-16): H4 b, H5 a, H6 a, H8 a/a, H10 a, and the watcher-network amendment.

  • _events.py:
    • A per-shift append-only events.jsonl, written inside the tick lock with no subprocess or network calls.
    • seq and dedup keys come from the file, so a crash can't repeat an event or reuse a seq.
    • Refusals are deduplicated; a ci event repeats only when the verdict changes.
  • pyauto-brain batch watch --stream [--from N] [--for S] [--json] [--check]: tails the stream and exits at shift end, on stop, on STOP, at the window close, or after --for. It makes no network calls.
  • New watcher verbs (from mention_login only, enacted once by comment id):
    • /cap merges|workers|tokens <n>: lower a cap, or raise it back up to the brief's value. _brief.effective is used everywhere caps are read, and tokens 0 really stops new close-outs.
    • /add <prompt>: goes through the claim, repo-claim and organ gates. It is refused within 30 min of review-at and makes exactly one Mind fetch.
    • /kill <task>: runs claude stop on that shift's own lease agent only, then re-dispatches once unless the task was /dropped. If claude stop fails, the ack says refused.
  • Needs-you comments: at most 5 + 1 per shift, no @. They are counted apart from pushes.
  • Digest: a cap-override line, the killed outcome, and the feat: glance public-name diff check — added or renamed public library names go to a human /prm #641 public-name and decision-taken refusal classes.
  • Doctrine: AUTONOMY items 1–3, dated 2026-11-16 and citing feat: shift event stream + batch watch --stream + /add /cap /kill (M3.4 build A) #644. batch/AGENTS.md lists the seven verbs.

Test plan

  • 70+ new tests, including a replay of the real 2026-11-14-pm3/tick.log. All 31 steering tests fail on main.
  • Full suite: 2138 passed. The 1 failure is environmental. Firewall and line counts pass.
  • Witness: the real CLI --stream over a 20-minute synthetic shift prints the required events in order (build_a_stream.txt) and exits 0.
  • Independent review: FINDINGS (/cap tokens 0 didn't stop close-outs, plus 5 follow-ups), fixed in 1d8a1b1. Re-review in progress.

Merge before the M3.5 inbox PR (#645), which rebases onto this.

🤖 Generated with Claude Code

Jammy2211 and others added 3 commits November 16, 2026 13:55
#644)

M3.4 Build A, the shift cockpit's engine.

- _events.py: record_tick appends one JSON line per new event to the slot's
  events.jsonl, inside the tick lock, from the tick's result and counters
  (no subprocess, no network). Keys dedup in the file itself, so a crash
  never repeats an event or reuses a seq; one cap line per shift-wide class.
- _orchestrator: record events in the open tick, finish_shift and late_sweep;
  out["health"] for ci lines; shift-end when nothing is left for the late
  sweep; needs-you event comments, at most 5 + 1 a shift, no @ (H4b).
- Steering verbs: /cap (never above the brief's own value, H6), /add
  (refused within 30 min of review-at; overrides exclude: and the parked
  hold, never the organ rule, H8; one Mind fetch per /add), /kill (local
  claude stop; the reap marks the exit killed, re-dispatched once unless
  dropped, H5). _brief.effective applies caps and added tasks per tick.
- batch watch --stream [--from --for --json --check]: prints the stream,
  exits 0 at shift-end, STOP or the window's end, 3 at a segment end.
- _batch.grade_text; _digest cap-override line, killed exit word, #641 and
  close-out refusal classes.
- Tests: events, stream, steering (one per verb and ack, all failing on
  main), and a replay of shift B's real tick.log (2026-11-14-pm3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AUTONOMY.md amendment 2026-11-16 items 1-3, approved by the human: the
per-shift events.jsonl, /add's one Mind fetch per command with /cap and
/kill's local claude stop, and needs-you event comments (at most 5 + 1 a
shift). /drop's "a running worker is not killed by the watcher" now ends
"unless the human commands /kill"; the revert condition names them all.
The batch skill and its reference list the new verbs and --stream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Close-out gates read `budget is not None`: a `/cap tokens 0` now stops
  close-outs, as its ack says (test).
- Needs-you event comments count as `event_comments`, apart from `pushes`,
  so the digest's push-test finding no longer fires on a normal shift; the
  digest names their count (test). AUTONOMY item 3 says so.
- Event keys are truncated before dedup (KEY_MAX), so a long key never
  repeats; a `ci` key carries the PR's line count, so a verdict that changes
  again is streamed again (tests).
- `batch watch --stream --from N` attaches after `shift-end` when N is before
  it, so a re-attaching cockpit gets the digest and shift-end (test).
- A comment at `/kill`: a crash before the counters write re-stops the same
  agent id at most.
- batch AGENTS.md: seven verbs, `/kill` is the watcher's, the event stream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit c55c4f4 into main Nov 16, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the feature/m34-engine branch November 16, 2026 14:20
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 event stream + batch watch --stream + /add /cap /kill (M3.4 build A)

1 participant