Skip to content

batch: derive backpressure, honour queue.md, emit merge order, check batch records #345

Closed

Description

@Jammy2211

Overview

Phase 4 of the mind-post-cortex epic (assessment gaps 3, 4, 5 and 7). The
batch conductor plans every shift as if the review queue were empty, ignores
the one file the human maintains by hand (queue.md), declines to say what
order the shift's PRs should be merged in, and leaves per-member outcomes
UNREVIEWED forever. lifecycle.py check never opens a batch record at all,
so a member citing a prompt path that does not resolve — the 2026-08-31-pm
record has one — is invisible.

Two PRs: PyAutoBrain (agents/conductors/batch/_batch.py, its AGENTS.md,
tests) and PyAutoMind (scripts/lifecycle.py check + tests, queue.md
contract wording, batches/AGENTS.md, the pm record's bad member line).

Prompt: PyAutoMind/active/mind_post_cortex_p4_batch_plan_fidelity.md.
Epic ledger: draft/maintenance/pyautomind/mind_post_cortex_epic.md.

Plan

  • Derive --awaiting-review from active.md instead of defaulting to 0:
    a row carrying a library-pr:/workspace-pr: key (phase 3's keys, the
    primary signal) or a status: containing awaiting-merge / PR open
    (the fallback for rows written before phase 3) is a task awaiting review.
    The flag still overrides; the plan header prints which source was used.
  • Wire queue.md order into the plan's ranking — a queued prompt outranks
    an unqueued one, and among queued the file order wins — then correct
    queue.md to say exactly what plan reads (that file, the draft/ backlog
    and the derived awaiting-review count; nothing live from GitHub).
  • Fill a per-member outcome: at batch collect from the ledger alone
    (complete/ record → merged; still in active.md → carried; a review
    ruling → rejected-at-review; otherwise unreviewed), record it on the
    batch record, and let the next plan report the previous slot's carried
    members first.
  • Emit a merge-order: block in the collect packet and the record —
    dispatch order, library repos first, same-repo members serialised. It is
    advice for the human's /prm sequence, never an action.
  • Two batch-record drift legs in lifecycle.py check: a member whose
    prompt path resolves nowhere (error), and a closed record with no
    review-minutes-actual: (warning — the only calibration there is). Fix the
    2026-08-31-pm record's bad member line as part of it.
Detailed implementation plan

Affected Repositories

  • PyAutoBrain (primary)
  • PyAutoMind

Suggested branch: feature/mind-post-cortex-p4-batch-fidelity

Branch survey: PyAutoBrain main clean, PyAutoMind main clean. The Mind leg
is stacked on phase 3 (feature/mind-post-cortex-p3-pr-ledger, PR #393):
phase 3 adds registry_multi, _record_fields and the cmd_check tail this
phase extends, and _as_root to tests/test_lifecycle_check.py. The Mind PR
therefore targets that branch and is retargeted to main after #393 merges.
PyAutoBrain branches from main — phases 2 and 3 touch _intake.py,
_sizing.py and skills, never _batch.py.

Implementation Steps

  1. _batch.py — derive_awaiting_review(mind): read active.md through the
    existing read_active(), count entries whose library-pr:/workspace-pr:
    keys carry a PR URL, or whose status: matches awaiting-merge /
    pr open / pr-open. CLI --awaiting-review defaults to None so a
    flag of 0 is still an override; _main_plan derives when it is absent.
    plan() records the source in backpressure["source"] and emit() prints
    it in the header.
  2. _batch.py — read_queue(mind): parse queue.md's ## <n>. <label>
    sections, keep kind: prompt entries with a ref:, in file order.
    queue_rank(record, queue) returns the entry index, or len(queue) for an
    unqueued prompt (match on the rel path, then the basename, so a prompt that
    moved still ranks). The pool sort becomes
    (queue_rank, review_minutes, priority_rank, path); emit() marks queued
    members and prints how many queue entries were read.
  3. _batch.py — member_outcome(member, ctx): complete/<slug>.md record
    exists → merged; a review file rules the member rejected →
    rejected-at-review; the member's active.md entry still exists →
    carried; else unreviewed. collect() puts it on each scored member and
    record_update() writes an - outcomes: block ( - <slug>: <outcome>),
    set on an open record and filled on a closed one, as delivered:/packet:
    already are.
  4. _batch.py — merge_order(members, dispatch_order): order by
    (library-touching first, then dispatch order), annotate each entry with why
    it sits there and which earlier member shares a repo with it. Rendered in
    collect_report()'s summary and written to the record as - merge-order:.
    plan() gains a carried list read from the previous record's outcomes:.
  5. agents/conductors/batch/AGENTS.md — document outcome:, merge-order:,
    the derived backpressure input and the queue read.
  6. lifecycle.py — batch_member_problems(root) (every top-level
    batches/*.md; parse the member grammar; a prompt-shaped path must resolve
    under draft/, active/ or complete/, by path or basename, or have
    existed in git history — a moved-and-absorbed prompt is not drift) and
    batch_record_warnings(root) (a record with review:/reviewed-at: and no
    real review-minutes-actual:). Wired into cmd_check's phase-3 tail:
    problems extend problems, warnings extend warnings.
  7. PyAutoMind/queue.md — replace the "reads this file, the backlog and the
    open-PR state" sentence with what plan actually reads.
    PyAutoMind/batches/AGENTS.md — the outcome:/merge-order: schema.
    batches/2026-08-31-pm.md L37 — cite the completion record that resolves
    and drop the false "a path that never existed" clause (git history shows the
    draft path existed and was deleted when the prompt was routed).
  8. Tests: PyAutoBrain/tests/test_batch_plan.py (derived count, flag override,
    queue order), test_batch_collect.py (outcomes, merge order) and the
    Cortex-conductor suite (the _batch substring trap in _cortex.py);
    PyAutoMind/tests/test_lifecycle_check.py (both legs fire, and stay quiet
    on a clean tree) with fictional fixtures only.

Key Files

  • PyAutoBrain/agents/conductors/batch/_batch.py — plan, emit, collect,
    record_update, the CLI.
  • PyAutoBrain/agents/conductors/batch/AGENTS.md — the record schema.
  • PyAutoMind/scripts/lifecycle.py — cmd_check and the two new legs.
  • PyAutoMind/queue.md, PyAutoMind/batches/AGENTS.md,
    PyAutoMind/batches/2026-08-31-pm.md.

Testing

pytest -q in both repos, plus python3 scripts/lifecycle.py check in Mind.
Known: test_cortex_conductor::test_a_fixture_tree_finds_the_schema_its_checkout_ships
fails in any task worktree (it reads the checkout's own schema), on main too.

Original Prompt

Click to expand starting prompt

Batch plan fidelity: derive backpressure, honour queue.md, emit merge order, check batch records

Type: feature
Target: pyautobrain
Repos:

  • PyAutoBrain
  • PyAutoMind
    Themes:
  • mind-workflow
    Difficulty: medium
    Autonomy: safe
    Priority: normal
    Status: draft
    Consequence: judge
    Witness: pyauto-brain batch plan --dry-run with a fixture active.md holding three awaiting-merge rows reports awaiting_review=3 without the flag and shrinks the proposal accordingly; a fixture queue.md order is reflected in priority_rank (top entry first among equals); batch collect on the 2026-08-31-pm fixture emits a merge-order: list that places library PRs before their workspace dependants and serialises same-repo members; lifecycle.py check flags a batch record member whose prompt path does not exist and a closed record with no review-minutes-actual:; all Brain and Mind tests pass
    Review-minutes: 20
    Unattended: ready
    Epic: mind-post-cortex
    Phase: 4
    Filed: 2026-09-03

Phase 4 of mind-post-cortex — assessment gaps 3, 4, 5 and 7. Two PRs: Brain
(agents/conductors/batch/_batch.py + tests) and Mind (lifecycle.py + docs).

  1. Derive --awaiting-review (gap 4, S). _batch.py ~L2978: the flag
    defaults to 0 and is never derived, so every plan assumes an empty review
    queue. Count active.md rows whose status: contains awaiting-merge /
    PR open (after phase 3, rows carrying a *-pr: key) and use that as the
    default; the flag overrides. Print the derived count in the plan header.
  2. Make queue.md's contract true (gap 5, S). queue.md L10-12 says the
    planner reads it and the open-PR state; plan() (~L160-260) reads neither.
    Wire queue order into priority_rank (a queued prompt outranks an
    unqueued one; among queued, file order wins) and correct the doc to say
    exactly what is read. Open-PR state = the derived count from item 1; say
    so.
  3. Dev batch outcome accounting (gap 3, M — the part not covered by
    carry-forward).
    Extend the batch record schema (batches/AGENTS.md)
    with a per-member outcome: of merged | rejected-at-review | carried | unreviewed and make batch collect fill it from the ledger (a
    complete/ record → merged; still in active.md → carried; review file
    ruling → rejected) rather than leaving decision: UNREVIEWED. The next
    plan reads the previous record's carried members first.
  4. Merge order in the packet (gap 7, M). collect declines today
    (~L1261-1264: "members is sorted by HEALTH, so it cannot drive a merge
    order"). Add a merge-order: block computed from dispatch_order +
    library-first (LIBRARY_REPOS) + shared-repo serialisation, rendered in
    the packet's summary and the record. It is advice for the human's /prm
    sequence, not an action.
  5. Batch-record drift checks (gap 7, S). lifecycle.py check: every
    batches/*.md member prompt: path must resolve (the pm record cites one
    that never existed, L37); a record with closed:/review present but no
    review-minutes-actual: warns ("the only calibration there is",
    batches/AGENTS.md L66). Fix the pm record's bad path as part of this.

Tests: extend PyAutoBrain/tests batch fixtures (mind the _batch substring
trap in _cortex.py noted in memory) and Mind tests/test_lifecycle*.py.

Activity

  1. Jammy2211 commented on Sep 3, 2026

    @Jammy2211
    ContributorAuthor

    Shipped to two PRs, both green — merge stays human.

    Test counts: PyAutoBrain 883 passed / 1 known worktree-only failure (test_cortex_conductor::test_a_fixture_tree_finds_the_schema_its_checkout_ships, which fails on main in a worktree too); PyAutoMind 394 passed, lifecycle.py check OK with one honest warning (the pm record's missing review-minutes-actual:).

    git merge-tree against the sibling phases: PyAutoBrain clean against both p2 and p3; PyAutoMind clean against p3 (its base), and against p2 the only conflicts are the generated dashboard pages — a control merge of p2 into p3 alone produces the identical hunks.

    Heart was RED at PR-open (PyAutoLens CI failure; release validation FAILED at stage integrate; PyAutoArray open PR 11d old). None touches this diff and the reason set is unacked for this task — merge needs your own call. Recorded verbatim on the active.md row.

    Two notes for whoever merges: the witness line names batch plan --dry-run, and there is no such flag — plan writes nothing, so it is dry by construction; and the merge order can only name repos it can see (prompt Repos:, PR URLs, the active.md row), so on a historical slot whose prompts were absorbed into completion records it falls back to dispatch order and says so.

  2. Jammy2211 commented on Sep 3, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    Phase 4 of the mind-post-cortex epic. Both PRs merged 2026-09-03.

    • PyAutoBrain#346 — merged d442df5d
    • PyAutoMind#394 — merged c00098e1

    Brain (agents/conductors/batch/_batch.py, its AGENTS.md, two test modules).
    --awaiting-review is derived from active.md instead of defaulting to 0 (a row
    carrying library-pr:/workspace-pr:, or a status: reading awaiting-merge /
    PR open); the flag still overrides and the plan header names the source.
    queue.md order is wired into the ranking — a queued prompt outranks an unqueued
    one, file order wins among queued, and an entry written against draft/… keeps
    its place after the prompt moves to active/. batch collect fills a per-member
    outcome: (merged | rejected-at-review | carried | unreviewed) from the ledger
    alone — no gh call — and emits a merge-order: block (dispatch order, library
    repos first, same-repo members serialised) as advice for the human's /prm
    sequence, never an action. The next plan reads the previous slot's carried
    members first.

    Mind (scripts/lifecycle.py, tests, queue.md, batches/AGENTS.md, the pm
    record).
    lifecycle.py check now opens the batch records: a member whose
    prompt: path resolves in no state folder and has never existed in git history
    is drift (error); a closed record with no review-minutes-actual: is a warning
    (and stays a warning — it is the only calibration there is). The check degrades
    to a single warning in a shallow clone, where "has this path ever existed" is
    unanswerable, so lifecycle_drift.yml now checks out at fetch-depth: 0.
    queue.md says what plan actually reads (this file, the draft/ backlog, the
    derived review-queue depth — nothing live from GitHub); batches/AGENTS.md
    documents the outcomes:/merge-order: schema; the 2026-08-31-pm record's
    subhalo-follow-up-wave member now cites a path that resolves, and its false
    "a path that never existed" clause is gone.

    CI green on both merge heads: Brain Tests pytest 3.12 + 3.13; Mind Dashboard
    Refresh, Lifecycle Drift and Spawn Drift.

    Closed out via /prm; record complete/2026/09/mind-post-cortex-p4-batch-fidelity.md.
    Next: phase 5 (Heart freeze flag, issue PyAutoHeart#196).

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