Skip to content

maintenance: shed the Cortex review-slot and gate apparatus #9

Closed

Description

@Jammy2211

Overview

Phase 1 of the cortex-checkin epic (ledger PyAutoMind/draft/maintenance/pyautocortex/cortex_checkin_epic.md). The Cortex's core — projects.yaml, phase files, append-only rulings, check/move/rule/new, collect's scorer, dashboard --apply — is right-sized. What is over the top is everything that models the human as a reviewer working a scheduled shift through a packet page: 0 conductor-opened slots, 0 rulings from a packet, 0 partial reviews, review-minutes-actual never filled, 2 gated refs and 0 gate flips, rule --also never used, Lane: local-dev on 32/32 phases, and a restricted-YAML parser whose own parity test proves it redundant.

This phase is deletion only, plus the one decoupling the phase-2 door needs: collect must run with no batch record. Every historical record stays readable — batches/2026-*.md and batches/reviews/*.md are cited verbatim by 13 rulings and are kept as read-only history.

Two PRs: PyAutoCortex (schema, scripts, workflows, tests, docs) and PyAutoBrain (cortex conductor, the batch conductor's cortex kind, status box, skills). Dev batching is untouched.

Plan

  • Retire gate grading in PyAutoCortex: delete gates_grade.yml (the daily cron), the gates --grade/--write path in scripts/cortex.py, the Gates-cleared:/Gate-override: header keys and the three check invariants over them. Keep the plain Gates: header, the gated state, GATE_REF_RE/gate_url and the read-only gates listing — a gated phase now moves to ready by a human typing move ready.
  • Delete rule --also (never used) and the Lane: header (one mechanical sweep over 32 phase files + schema, check, the new template and the "laptop lane" prose).
  • Replace the restricted-YAML parser (parse_projects + its six parity tests) with yaml.safe_load, keeping the field validation; declare pyyaml in cortex_check.yml and the README install line.
  • Delete the batch record + packet schema: batches/packets/, the batch-record schema in REFERENCE.md, the slot/shift/review-minutes/partial-review vocabulary in batches/AGENTS.md, and batch_problems/_review_section_problems in cortex.py. Keep the records and reviews themselves as history with a two-line batches/AGENTS.md saying exactly that; the ruling Batch: field becomes optional-historical.
  • Decouple collect from the batch record: collect --pull --apply with no record now scopes to every phase in submitted|running; --phase REL narrows; --slot goes away. apply_ops still moves running → pulled → awaiting-ruling; the record-rewrite leg is deleted.
  • Delete the cortex kind from the batch conductor in PyAutoBrain (plan_cortex, cortex_plan_record, carried members, CORTEX_CHIPS, partial reviews, the cortex lane gate, the cortex --push integration legs) and the Cortex status box from _status.py and its render call in _cortex.py.
  • Delete the plan verb and the gates --grade --apply wrapper from the cortex conductor. Keep census, dashboard, the decoupled collect, and every payload builder — phases 2 and 3 build on them.
  • Update the skills and docs to match, delete the tests of deleted things, keep every test of a kept thing green, and regenerate the Cortex dashboard (it loses the status box).
Detailed implementation plan

Work Classification

Library (both repos are agent/tooling source, shipped via /ship_library).

Affected Repositories

  • PyAutoCortex (primary)
  • PyAutoBrain

Branch Survey

Repository Current Branch Dirty?
./PyAutoCortex main clean
./PyAutoBrain main clean

No worktree claim on either repo in active.md (claims held by gaussian-precompute-p2, euclid-cpu-two-stage-route, image-source-mappings-p3 — no overlap).

Suggested branch: feature/cortex-checkin-p1-shed-review-slot
Worktree root: ~/Code/PyAutoLabs-wt/cortex-checkin-p1-shed-review-slot/

Implementation Steps — PyAutoCortex

  1. Gate grading. Delete .github/workflows/gates_grade.yml. In scripts/cortex.py delete GATE_JQ, _http_gate, fetch_gate_states, grade_gate and the --grade/--write half of gates_report (~L929-1092), plus the --grade/--write/--apply flags on the gates subparser. Keep GATE_REF_RE, DEFAULT_GATE_OWNER, gate_refs, gate_url and the read-only listing. Drop Gates-cleared/Gate-override from PHASE_KEYS and the three gate invariants in phase_problems; drop GATES_SETTLED_STATES/GRADED_STATES if they become unused. Update AGENTS.md (workflow table + "the one scheduled job that mutates the ledger"), REFERENCE.md (~L148-157) and append a dated entry to docs/schema_decisions.md: gate grading retired 2026-09-03; sequencing is prose Ready when: per decision 54.
  2. rule --also. Remove the flag from the rule subparser, the fan-out in rule_phase/cmd_rule, its tests and its docs.
  3. Lane:. Remove LANE, the key from PHASE_KEYS, the check invariant, the new template line, the line from all 32 phases/**/*.md files and the skeleton fixtures, and the "laptop lane" prose from AGENTS.md.
  4. PyYAML. Replace parse_projects (~L290-400), _strip_comment, _scalar and _finish_row with a yaml.safe_load load in load_projects, keeping the field validation (PROJECT_FIELDS, PROJECT_OPTIONAL_FIELDS, PROJECT_STATUSES, PARTITIONS, path shape) as problems. Delete the six parity tests; keep the field-validation tests. Add pyyaml to the cortex_check.yml pip line and the README install line.
  5. Batch record + packet schema. git rm -r batches/packets/; delete batch_problems, _review_section_problems, _record_members, _record_values, MEMBER_RE, REVIEW_SECTION_RE, REVIEW_KEY_RE, REVIEW_PART_RE, SLOT_RE (~L772-893) and their check wiring plus tests. batch_records/batch_reviews stay only if a kept caller needs them. Rewrite batches/AGENTS.md to two lines ("read-only history; never modified, only added"), delete the batch-record schema section from REFERENCE.md, make ruling Batch: optional-historical in the schema, and drop batches/packets/** from pages_dashboard.yml. State the batches/ decision in scripts/ledger_merge.py (history: never modified, only added) and fix tests/test_ledger_merge.py.
  6. collect decoupling is Brain-side (step 9) — the Cortex docs must stop documenting --slot.

Implementation Steps — PyAutoBrain

  1. agents/conductors/batch/_batch.py: delete plan_cortex (~L3050), cortex_plan_record (~L3154), carried_members (~L3208) and the carried:/carried-from: keys, CORTEX_CHIPS (~L2724) and the cortex packet rendering, REVIEW_PART_RE/_next_review_path (~L2737-2768, shipped as PyAutoCortex#7 / PyAutoBrain#342 — revert cleanly), --kind cortex on plan/collect and _main_plan_cortex, the cortex lane gate (detect_lane ~L962 stays only if dev uses it), and the cortex --push legs in _integration.py (~L328/430).
  2. agents/conductors/batch/_status.py (~L196): delete the Cortex status box render and the strip _cortex.py prints above "awaiting", plus the render call in agents/conductors/cortex/_cortex.py.
  3. agents/conductors/cortex/_cortex.py: delete the plan verb (plan, emit_plan ~L972-1050) and the gates --grade --apply wrapper (~L1856). Rework cmd_collect (~L1727-1745) so it no longer requires a record or --phase: default scope = every phase in submitted|running; --phase REL narrows; --slot is gone. run_pull (~L1701), apply_ops (~L1658) and _apply_checked (~L1802) keep the running → pulled → awaiting-ruling moves; the record-rewrite leg goes. Keep census, dashboard, collect, _ruling_payload, launch_payload, _live_payload, _epic_payload, _project_payload.
  4. Docs/skills: skills/batch/batch.md science section (~L152-176) → one paragraph pointing at /cortex (installed in phase 2); skills/cortex/cortex.md verb menu loses plan and gates --grade; agents/conductors/cortex/AGENTS.md and agents/conductors/batch/AGENTS.md (~L545-600 rolling-board / carry prose) updated; the skills/COMMANDS.md /cortex row stays.
  5. Tests: delete the tests of deleted things, keep the rest green. Mind the _batch substring trap in _cortex.py and the tenant firewall (no real org/repo names in new fixtures).

Verification

  • PyAutoCortex pytest -q and python3 scripts/cortex.py check.
  • PyAutoBrain pytest -q (one known worktree-only failure: test_cortex_conductor::test_a_fixture_tree_finds_the_schema_its_checkout_ships).
  • Regenerate the Cortex dashboard from inside the Cortex checkout against this branch's Brain worktree: python3 ../PyAutoBrain/agents/conductors/cortex/_cortex.py dashboard --cortex . --apply, then confirm dashboard --check is current.
  • The prompt's Witness: grep (excluding the prompt and record files themselves).

Key Files

  • PyAutoCortex/scripts/cortex.py — 1640 lines; the gates stack, parse_projects, batch_problems, rule --also.
  • PyAutoCortex/.github/workflows/{gates_grade,cortex_check,pages_dashboard}.yml
  • PyAutoCortex/{AGENTS.md,REFERENCE.md,README.md,docs/schema_decisions.md,batches/AGENTS.md}
  • PyAutoBrain/agents/conductors/batch/{_batch.py,_status.py,_integration.py,AGENTS.md}
  • PyAutoBrain/agents/conductors/cortex/{_cortex.py,AGENTS.md}
  • PyAutoBrain/skills/{batch/batch.md,cortex/cortex.md}

Out of scope (epic ledger)

Collapsing the 10-state phase machine; Migrated-from: headers and docs/schema_decisions.md history; rewriting the seven per-project hpc/sync CLIs. projects.yaml and rulings/ are code / append-only and are not modified.

Original Prompt

Click to expand starting prompt
# Cortex: shed the review-slot and gate apparatus the check-in loop never uses

Type: maintenance
Target: pyautocortex
Repos:
- PyAutoCortex
- PyAutoBrain
Themes:
- mind-workflow
Difficulty: medium
Autonomy: safe
Priority: high
Status: draft
Consequence: judge
Witness: in PyAutoCortex `grep -rn "gates_grade\|Gates-cleared\|Gate-override\|--also\|^Lane:\|review-minutes\|packets/" --include=*.md --include=*.py --include=*.yml . ` returns only `complete`-style history under `batches/reviews/` and `rulings/`; `.github/workflows/gates_grade.yml` and `batches/packets/` are gone; `scripts/cortex.py` imports `yaml` and has no `parse_projects` hand parser; in PyAutoBrain `grep -rn "plan_cortex\|cortex_plan_record\|carried_members\|CORTEX_CHIPS\|REVIEW_PART_RE\|_next_review_path" agents/ board/ skills/` returns nothing; `pyauto-brain cortex collect --pull --apply` runs with NO batch record and no `--phase` and scores every submitted/running phase; `pyauto-brain cortex dashboard --check` is current with no status box; Cortex `pytest -q`, Brain `pytest -q` and `cortex.py check` pass; the dashboard renders every existing section except the status box
Review-minutes: 20
Unattended: ready
Epic: cortex-checkin
Phase: 1
Filed: 2026-09-03

Phase 1 of `cortex-checkin` (ledger `draft/maintenance/pyautocortex/cortex_checkin_epic.md`).
Two PRs: PyAutoCortex (schema, scripts, workflows, tests, docs) and PyAutoBrain
(conductor, batch cortex kind, status box, skills). Deletion only, plus the one
decoupling the door needs (item 6). Keep every historical record readable.

## Delete — PyAutoCortex

1. **Gate grading**: `.github/workflows/gates_grade.yml`; in `scripts/cortex.py`
   the `gates --grade/--write` path (`_http_gate`, `fetch_gate_states`,
   `grade_gate`, `gates_report` ~L929-1092) and its tests; the
   `Gates-cleared:` / `Gate-override:` keys and the three `check` invariants
   that reference them (REFERENCE.md ~L148-157). KEEP the plain `Gates:`
   header, the `gated` state, `GATE_REF_RE`/`gate_url` and the read-only
   `gates` listing (no `--grade`): a gated phase is moved to `ready` by a
   human typing `move ready`. Update AGENTS.md/REFERENCE.md/schema_decisions
   (append a dated decision: "gate grading retired 2026-09-03; sequencing is
   prose `Ready when:` per decision 54").
2. **`rule --also`** fan-out (never used) — remove flag, code, tests, docs.
3. **`Lane:`** header — remove from the schema, `check`, `new` template, the
   32 phase files (one mechanical sweep), and the "laptop lane" prose in
   AGENTS.md. Brain's `_batch.py` lane filter for cortex kind goes with item 7.
4. **Restricted-YAML parser** (`parse_projects` ~L290-400 + the six parity
   tests): replace with `yaml.safe_load` and keep the FIELD validation
   (required keys, `status` values, path shape). Add `pyyaml` to whatever
   declares Cortex's deps (`cortex_check.yml` pip line, README install line).
5. **Batch record + packet schema**: delete `batches/packets/` (TEMPLATE.md,
   AGENTS.md, the three HTML files), the batch-record schema section in
   REFERENCE.md and `batches/AGENTS.md`'s slot/shift/review-at/review-minutes
   vocabulary and partial-review (`-r<N>`) rules, and `batch_problems` +
   `_review_section_problems` in `cortex.py` (~L772-893) with their tests.
   KEEP `batches/2026-*.md` and `batches/reviews/*.md` as read-only history
   (the human's verbatim words are cited by 13 rulings) — add a two-line
   `batches/AGENTS.md` saying exactly that, and make the ruling `Batch:`
   field optional-historical in the schema. Ledger-merge classification for
   `batches/` becomes "history: never modified, only added" or drop the path
   from the classifier — state which.
6. **Decouple `collect` from the record** (Brain side, but list it here so the
   Cortex side does not still document `--slot`): the door needs
   `collect --pull --apply` with no record: default scope = every phase in
   `submitted|running`, `--phase REL` narrows, `--slot` goes away.
   `apply_ops` keeps moving `running → pulled → awaiting-ruling`; the record
   rewrite leg is deleted.

## Delete — PyAutoBrain

7. In `agents/conductors/batch/_batch.py`: `plan_cortex`, `cortex_plan_record`,
   `carried_members` / `carried:` / `carried-from:`, `CORTEX_CHIPS` and the
   cortex packet rendering, `REVIEW_PART_RE` / `_next_review_path` (partial
   reviews, shipped as PyAutoCortex#7 / PyAutoBrain#342 — revert cleanly),
   `--kind cortex` on `plan`/`collect` entirely, the cortex lane gate
   (`detect_lane` stays for dev if dev uses it; delete if cortex-only), and
   `--push` integration for the cortex kind (`_integration.py`). Dev batching
   is untouched.
8. `agents/conductors/batch/_status.py`: the Cortex status box and the strip
   `_cortex.py` renders above "awaiting" (dashboard shows "No batch in
   flight" today). Delete the render call in `_cortex.py` too.
9. `agents/conductors/cortex/_cortex.py`: the `plan` verb (`plan`, `emit_plan`
   ~L972-1050), the `gates --grade --apply` wrapper (~L1856), `--slot` on
   `collect` (item 6). Keep `census`, `dashboard`, `collect` (decoupled),
   the payload builders (`_ruling_payload`, `launch_payload`, `_live_payload`,
   `_epic_payload`, `_project_payload`) — phase 2 and 3 build on them.
10. Skills/docs: `skills/batch/batch.md` science section (~L152-176) → one
    paragraph pointing at `/cortex` (phase 2); `skills/cortex/cortex.md` verb
    menu loses `plan` and `gates --grade`; `agents/conductors/cortex/AGENTS.md`
    and `batch/AGENTS.md` (~L545-600 rolling-board / carry prose) updated;
    `skills/COMMANDS.md` row for `/cortex` stays (phase 2 installs it).
11. Tests: delete the tests of the deleted things; keep every test of a kept
    thing green. Mind the `_batch` substring trap in `_cortex.py` noted in
    memory, and the tenant firewall (no real org/repo names in new fixtures).

Then: Cortex `pytest -q` + `python3 scripts/cortex.py check`; Brain `pytest -q`
(one known worktree-only failure: `test_cortex_conductor::test_a_fixture_tree_finds_the_schema_its_checkout_ships`);
regenerate the Cortex dashboard from inside the Cortex checkout
(`python3 ../PyAutoBrain/agents/conductors/cortex/_cortex.py dashboard --cortex . --apply`)
and confirm `--check` is current; open both PRs.

Activity

  1. Jammy2211 commented on Sep 3, 2026

    @Jammy2211
    ContributorAuthor

    Shipped to PRs — merge stays human

    Both halves of phase 1 are open on branch feature/cortex-checkin-p1-shed-review-slot:

    • PyAutoBrain#348 — the batch conductor's cortex kind, the status box, the plan verb and the gate-grading wrapper; collect decoupled from the batch record.
    • PyAutoCortex#10 — gate grading, the batch/packet schema, rule --also, Lane:, the hand-rolled YAML parser.

    Merge order: PyAutoBrain#348 first. dashboard_refresh.yml in this repo renders through PyAutoBrain main, so #10's refresh check stays red until #348 lands; the other direction is safe because the new conductor works against either script. #10's check job (cortex.py check + pytest) is green on its own tree.

    Verification

    before after
    PyAutoCortex pytest -q 134 passed 115 passed
    PyAutoBrain pytest -q 903 collected 864 passed, 0 failed
    cortex.py check OK OK
    cortex dashboard --check current current (regenerated; the status box is gone)

    Lines deleted: scripts/cortex.py 1640 → 1334; _batch.py 3727 → 2862; _cortex.py 1967 → 1734; _status.py −80.

    What collect now accepts

    pyauto-brain cortex collect [--phase REL]... [--pull] [--refreshed ISO] [--apply] [--out FILE] [--cortex DIR]
    

    --slot is gone with the record it named. Default scope: every phase in submitted | running. --phase REL narrows. --apply still needs a refresh stamp and still moves running → pulled → awaiting-ruling, rehearsed on a copy; it writes nothing else.

    Left undone (prompt item 2)

    rulings/AGENTS.md still documents rule --also in one sentence. rulings/ is append-only and was out of bounds for this phase; it is a one-line fix for whoever next edits that file.

    Heart

    RED at ship time and not acknowledged: "release validation FAILED (stage integrate)", "PyAutoArray: open PR 11d old". Both are release-chain facts about other repos; neither organ here is in the release chain. PRs were opened, nothing was merged.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_013HsZA1ufn3msgPiDFxEXa6

  2. Jammy2211 commented on Sep 4, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    Phase 1 of the cortex-checkin epic — the review-slot and gate apparatus is retired.

    PR Merge sha
    PyAutoLabs/PyAutoBrain#348 fc1cb32f6e226ddd2da24448769f1f77ebed6421
    #10 6cd6220e8e86711919c8261d3230564f22b09036

    Both merged to main on 2026-09-04, Brain before Cortex (the Cortex refresh
    workflow renders through PyAutoBrain main, so its check only goes green once
    the matching Brain PR has landed — it did, on the re-run).

    PyAutoCortex#10 needed a merge of origin/main into its branch first: main
    had moved under it (the dashboard self-heal commit 1a39784 and the gate-grade
    commit 1815c69), conflicting on the two generated pages. Resolved by
    regenerating dashboard.md + dashboard.html with the phase-1 renderer rather
    than hand-resolving them, keeping main's gate flip (State: ready) on
    phases/euclid/dr1_prelim_10_lens_science_run.md and dropping the
    Gates-cleared: key this phase retires (schema decision 58). Merge commit
    2ddb47b.

    Heart was RED at merge time with two reasons — "release validation FAILED
    (stage integrate)" and "PyAutoArray: open PR 12d old" — both release-chain facts
    about other repos. Neither PyAutoBrain nor PyAutoCortex is in the release chain,
    so the merge went ahead under an explicit human acknowledgement.

    Closed by /prm.

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