Skip to content

policy: shift cockpit watch carve-out + hook guards Monitor/background GitHub polls (PyAutoBrain#646) - #575

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

Jammy2211 merged 3 commits into
mainfrom
feature/m34-cockpit

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

The doctrine-and-hook half of M3.4 build C (PyAutoLabs/PyAutoBrain#646). Human rulings 2026-11-16, all as recommended (Science/scratch/m3_4_m3_5_design/HUMAN.md):

  • H1 (a): the carve-out as worded;

  • H2 (b): the watch may run until 45 min after review-at;

  • H3 (a): block any Monitor that touches GitHub or a WebSocket;

  • H3b (a): block background Bash that polls GitHub.

  • policy/shift_cockpit_watch.md (new): the design's §3.1 carve-out, word for word. A chat may keep one Monitor on the shift's local event stream, requested by the human, only inside the shift window (30 min before dispatched: until 45 min after review-at:), and it ends with the shift. A v1 Limits note lists the textual gaps.

  • end_at_deliverable.md stays at its 10-line cap, because it is stamped into every AGENTS.md. It now bans a Monitor or background loop on GitHub and points to the new page; "draining usage" is kept. shift_watcher.md points to the page.

  • The hook (end_at_deliverable_hook.sh):

    • The canonical stream command is matched whole, with characters limited to [A-Za-z0-9._/ -], and pinned to the resolved Brain/Mind checkouts. The window comes from the shift record and fails closed.
    • A Monitor on gh, a fetching git, github.com, claude agents, ci_verdict or a WebSocket is refused, and so is a background Bash loop on GitHub.
    • Foreground Bash takes a bash fast path (about 9 ms, down from 90). The payload is read on stdin, so large commands are judged rather than failing open.
  • repos_sync.py: --check now flags a stale matcher and --write refreshes it. Before, the matcher never propagated.

On merge, the propagate workflow writes the hook copy, settings.json matcher, .codex/hooks.json and AGENTS.md block together, one commit per repo, about 49 repos. Codex users must re-trust the changed hook hash.

Test plan

  • Hook tests: 135, including 17 injection cases, a payload over 200 KB, pinning, window edges (−29/−31 min, +44/+46 min) and fast-path parity.
  • Mind suite: 1004 passed. repos_sync --check shows no Mind drift. lifecycle.py check OK.
  • Independent review: FINDINGS (stream-command injection, payloads over 128 KB failing open, speed, pinning), fixed in 00b2097d7. Re-review CLEAN (204 tests).

🤖 Generated with Claude Code

Jammy2211 and others added 3 commits November 16, 2026 13:08
PyAutoBrain#646. Human rulings H1 (a), H2 (b) 45 min, H3 (a), H3b (a).

- policy/shift_cockpit_watch.md: the DESIGN 3.1 carve-out, worded as
  approved. It is its own page because end_at_deliverable.md is stamped
  into every repo's AGENTS.md and capped at 10 lines; that file now bans a
  Monitor or background loop on GitHub and points at the carve-out.
- shift_watcher.md: the one sentence on the cockpit watch.
- end_at_deliverable_hook.sh: Monitor runs only the canonical
  `pyauto-brain batch watch --stream --record .../batches/<slot>.md` from
  dispatched - 30 min to review-at + 45 min (fail closed on an unreadable
  record); any other form naming the watcher is refused; a Monitor naming
  GitHub (gh, fetching git, github.com, claude agents, ci_verdict) or a
  WebSocket is refused; local tails pass. A background Bash loop on GitHub
  is refused; foreground Bash always passes. Refusals say: read CI once in
  the foreground, report and hand back.
- repos_sync.py: Monitor and Bash join DELIVERABLE_HOOK_MATCHER; --check
  now flags a settings.json registering the hook under a stale matcher and
  --write refreshes it in place (before, only the command was compared, so
  the widened matcher would never have propagated).
- Mind's own generated copies regenerated; other repos follow via the
  propagate workflow after merge.

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

Findings on 767be8c03 (PyAutoBrain#646):

- The stream command is matched whole and unstripped, every character in
  [A-Za-z0-9._/ -], so `;`, `$IFS`, backticks, `$( )`, quotes, globs,
  redirections and newlines can no longer ride on an allowed stream.
- The CLI and the record are pinned to the Brain and Mind checkouts the
  workspace's own resolver names (PYAUTO_ROOT, else the `.pyauto-root`
  above the hook, then PyAutoBrain/agents/_repo_paths.py); a CLI that merely
  exists elsewhere is refused, and no resolvable workspace fails closed.
- The payload reaches Python on stdin, not an env var: a call over 128 KB
  no longer fails to start Python (exit 126, which failed open).
- A bash fast path allows a foreground Bash call before Python starts
  (90 ms -> 9 ms per call); anything ambiguous still goes to Python.
- end_at_deliverable.md says "draining usage" again, still 10 lines.
- shift_cockpit_watch.md lists the v1 limits (textual false refusals and
  false passes).

Propagation: session_hook_propagate.yml writes the hook copy and the
settings.json matcher through write_session_hooks and commits them in one
commit per repo, so the new matcher never lands beside the old hook. Codex
users must re-trust the changed hook hash in `/hooks`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A PR that edits policy/end_at_deliverable.md cannot make the other repos'
AGENTS.md blocks match on their cloned mains: the per-repo regeneration
wave writes them after merge. The gate now decides `deliverable_pr` from
the PR's diff (independent of the hook, filing, map and Codex decisions),
asserts PyAutoMind's own block first, then drops only
`end-at-deliverable blocks (generated)` with the same loud banner. The
policy joins the push and pull_request path filters, so the leg is still
graded on every other PR and on push to main. repos_sync gains a
DELIVERABLE_BLOCKS label constant; workflow tests cover the decision, the
skip, its composition and the compensating control.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 0641686 into main Nov 16, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/m34-cockpit branch November 16, 2026 14:04
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.

1 participant