Skip to content

feat(cortex): one check-in door — pull, score, render, push, summarise by project - #350

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/cortex-checkin-p2-the-door
Sep 4, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/cortex-checkin-p2-the-door

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Phase 2 of the cortex-checkin epic (#349). Stacked on #348 — retargets to main when it merges. The Cortex half is PyAutoLabs/PyAutoCortex#11, stacked on PyAutoCortex#10.

What this adds

pyauto-brain cortex checkin — the verb behind "where is my science?". It composes the primitives phase 1 decoupled (run_pull, score_phase, _apply_checked, render_pages, the payload builders) and reasons nothing extra of its own:

  1. Sync. Every status: active row of projects.yaml, plus any project owning a phase in submitted | running — a dormant project with a job still out there is still out there. Each is pulled with its own <local_path>/<sync_cli> pull, the verb all seven implement. Output is streamed, not captured: a pull runs for minutes and the human is watching this one command. A non-zero exit is recorded against that project and the sweep continues.
  2. Manifest. After a good pull, <pull root>/.cortex/pull.json gets project / pulled_at / cmd / rc / phases_live — merged into whatever the project's own CLI already wrote there. autolens_profiling's hpc/sync writes the checkpoints / runs tables that are the only window onto the RAL-only checkpoint.hdf5; clobbering them would blind the scorer's checkpoint leg.
  3. Score + move. collect's scorer over every live phase, then the same rehearsed _apply_checked moves (running → pulled → awaiting-ruling).
  4. Render. dashboard.md + dashboard.html.
  5. Push. claude/checkin-<YYYY-MM-DD> cut from a fresh origin/main, explicit paths, no force, never main — and refused before the branch is cut if scripts/ledger_merge.py classify calls the diff code.
  6. Summarise, by project, last — so a chat sees it above the fold. Per project: local_path / mirror / RAL root, what the pull did, phase counts, and every phase a human could act on today with its health verdict, the run dirs and logs the scorer touched, and the fenced copy-ready prompt its state already has.

The push rule

--push is allowed only when gh auth status succeeds and the Cortex checkout is clean on main — read before anything is written, since "clean" stops being true the moment the phases move. That is the whole cloud/laptop split and it is also the default: a laptop pushes without asking, a cloud session cannot and is told so. Stated in the output either way.

/cortex, installed rather than advertised

skills/COMMANDS.md has advertised /cortex since the conductor was born; ~/.claude/commands/cortex.md never existed. The skill body is now the check-in sequence (verbs demoted to an appendix), the stale plan / gates --grade rows retired in phase 1 are gone, and the committed .claude/{commands,skills} + .codex/skills discovery links exist alongside the other 29 commands. bin/install.sh needed no change — it already links skills/<verb>/<verb>.md; nobody had run it since the skill was added.

Tests

tests/test_cortex_conductor.py gains a check-in block over the existing board fixture: the dry-run listing (projects, exact pull commands, phases, nothing written), dry-run-is-the-default, per-project pull-failure isolation (a fake sync_cli exiting 1 for one project — the other still pulls, every phase is still scored, the failure lands on the right project and the exit code is 1), manifest write, merge-not-clobber, --skip-pull running no CLI, --project, the summary's by-project keying and its position last, the render leg leaving dashboard --check clean, the no-push path, the preflight refusing anything that is not a clean main, and the push refusing a code-classified diff. No test runs a real hpc/sync pull — every pull under test is a fake script, and no fixture names a real org or repo.

python3 -m pytest -q: 874 passed, 3 failed → tests/test_gh_surface.py was mine (the new skill body mentions gh auth status; it now points at GITHUB_ACCESS.md) and is fixed; the two tests/test_branch_sweep.py failures reproduce unchanged on the phase-1 base and are not this branch's. Targeted re-run of test_cortex_conductor.py + test_skill_install.py + test_gh_surface.py: 68 passed.

Verified live, without touching RAL

checkin --dry-run against the real Cortex: 3 active projects (euclid, inference_programme, subhalo_validation), the exact cd … && hpc/sync pull for each, 2 live phases (both subhalo_validation), and push would be: yes. It SSHes nowhere. --apply was exercised only against fixtures, deliberately: a real pull is minutes of RAL traffic and the human's call.

Noted, not fixed

bin/install.sh --check-project-discovery reports pre-existing drift unrelated to this branch (batch / start_bundle missing from the committed links, register_and_iterate / run_queue present and unwanted). Nothing checks it in CI. Left alone rather than swept into a cortex PR.

Closes #349 (with PyAutoCortex#11).

🤖 Generated with Claude Code

https://claude.ai/code/session_013HsZA1ufn3msgPiDFxEXa6

…e by project

`pyauto-brain cortex checkin` is the verb behind "where is my science?". It
composes the primitives phase 1 decoupled and reasons nothing extra of its own:

1. Sync — every `status: active` project in `projects.yaml`, plus any project
   owning a phase in `submitted | running`, pulled with **its own**
   `<local_path>/<sync_cli> pull`. Output is streamed, not captured: a pull
   runs for minutes and the human is watching this one command. A non-zero
   exit is recorded against that project and the sweep continues — one
   unreachable mirror must not hide the other six. After a good pull it writes
   `<pull root>/.cortex/pull.json` (`project`, `pulled_at`, `cmd`, `rc`,
   `phases_live`), **merged** into whatever the project's own CLI already
   wrote there, so the richer `checkpoints`/`runs` tables the scorer's
   checkpoint leg reads survive untouched.
2. Score + move — `collect`'s scorer over every live phase, then the same
   rehearsed `_apply_checked` moves.
3. Render — `dashboard.md` + `dashboard.html`.
4. Push — `claude/checkin-<date>` cut from a fresh `origin/main`, explicit
   paths, no force, never `main`, and refused before the branch is cut if
   `scripts/ledger_merge.py classify` calls the diff code. Allowed only when
   `gh auth status` succeeds AND the Cortex is clean on `main` — read before
   anything is written, because "clean" stops being true the moment the phases
   move. That is the cloud/laptop split, and it is also the default.
5. Summarise, by project, LAST — so a chat sees it above the fold: each
   project's paths, what its pull did, its phase counts, and every phase a
   human could act on today with its health verdict and the fenced,
   copy-ready prompt its state already has.

`--dry-run` is the default and reaches nothing at all: it prints the exact pull
command per project, the pull root, and every phase it would score.
`--project KEY` narrows; `--skip-pull` re-scores offline, stamping the refresh
from the newest manifest.

`/cortex` is installed rather than merely advertised: the skill body is now the
check-in sequence with the verbs as an appendix, and the committed
`.claude`/`.codex` discovery links exist alongside the other 29 commands.

Tests: dry-run listing, per-project pull-failure isolation (a fake `sync_cli`
exiting 1 for one project — the other still pulls and every phase is still
scored), manifest write and merge-not-clobber, `--skip-pull`, `--project`, the
summary's ordering and by-project keying, the render leg leaving the board
current, the no-push path, and the push refusal on a code-classified diff. No
test runs a real `hpc/sync pull`.

Stacked on #348 — retargets to main when it merges.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013HsZA1ufn3msgPiDFxEXa6
Base automatically changed from feature/cortex-checkin-p1-shed-review-slot to main September 4, 2026 13:44
@Jammy2211
Jammy2211 merged commit 9a039d9 into main Sep 4, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/cortex-checkin-p2-the-door branch September 4, 2026 14:21
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(cortex): the one check-in door — pull, score, render, push, summarise by project

1 participant