diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a0ad5517..f61e50ea 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -73,6 +73,19 @@ jobs: with: repository: PyAutoLabs/PyAutoCortex path: PyAutoCortex + # A Brain branch that changes the conductor alongside a Cortex schema + # change is tested against the Cortex branch of the SAME NAME when one + # exists (the two land as a pair), and against Cortex main otherwise. + - name: Prefer the same-named PyAutoCortex branch, if any + working-directory: PyAutoCortex + env: + BR: ${{ github.head_ref || github.ref_name }} + run: | + if git fetch --depth 1 origin "$BR" 2>/dev/null; then + git checkout -q FETCH_HEAD && echo "PyAutoCortex @ $BR" + else + echo "PyAutoCortex @ main (no branch named $BR)" + fi - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: diff --git a/AGENTS.md b/AGENTS.md index 80bd926b..e7eb9afd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,7 +18,7 @@ Canonical boundaries live in `PyAutoBrain/ORGANISM.md`; the full body map |-------|------|------| | **Brain** | PyAutoBrain | Reasoning/orchestration layer; how work is decomposed and routed; the specialist agents. | | **Mind** | PyAutoMind | Intent, goals, priorities, workflow state; every task starts as a markdown prompt here. | -| **Cortex** | PyAutoCortex | The Cortex — where the organism learns what is true: the science body map (`projects.yaml`) and the rulings of record for every science run; the science mirror of the Mind (runs and rulings, not prompts and PRs). | +| **Cortex** | PyAutoCortex | The Cortex — where the organism keeps track of what is true: the science body map (`projects.yaml`) and one ledger per science project (what was run, what came back, what was learned, where to pick up); the science mirror of the Mind (runs and a dated log, not prompts and PRs). | | **Memory** | PyAutoMemory | Long-term scientific/software/project knowledge (see science pointer below). | | **Heart** | PyAutoHeart | Health/readiness — the authoritative "is it safe to release?" verdict. | | **Hands** | PyAutoHands | Packaging, tagging, notebook generation, PyPI release execution. | @@ -141,7 +141,7 @@ the `/` slash commands. | `workspace` | The voice — the organism's expressive function: plan/survey workspace + HowTo example authorship (workspace\|howto registers) — WorkspaceDecision (never writes) | `bin/pyauto-brain workspace` | | `eyes` | The perceptive function — the organism's sense of its own appearance: survey/review a visualization workspace's figure surface, critiques route to intake/start_dev — EyesSurvey/EyesReviewSurface (never renders, never edits) | `bin/pyauto-brain eyes` | | `profiling` | The proprioceptive function — the organism's sense of its own effort: campaign/ingest/triage plans over the autolens_profiling workspace — ProfilingDecision | `bin/pyauto-brain profiling` | -| `cortex` | The learning function — where the organism finds out what is true: the science check-in over PyAutoCortex ('cortex checkin') — pull every active project through its own sync CLI, score every live run against its pre-registered witness, move what came back to awaiting-ruling, re-render the board and summarise it by project; its door never submits a run and never writes a ruling; the agent submits only on the human's ask, and the ruling is the human's word | `bin/pyauto-brain cortex` | +| `cortex` | The learning function — where the organism keeps track of what is true: the per-project science ledger over PyAutoCortex ('cortex checkin') — pull every active project through its own sync CLI, show where each run stands, re-render the board; it records cluster facts and the human's words, never a verdict of its own | `bin/pyauto-brain cortex` | | `hygiene` | The maintenance function — the organism's sense of its own upkeep: code-quality debt (dev-loop cost + tidiness), delegating fixes — HygieneDecision | `bin/pyauto-brain hygiene` | | `clone` | The Mitosis Agent: partition the reference assistant, analyze the domain, emit the CloneDecision; --apply --mode lightweight-seed delegates the seed birth to Build; 'clone sync' patches the reference's generic-file diff onto the born siblings (dry run by default; rejected hunks are a human decision) | `bin/pyauto-brain clone` | | `build` | Coordinate execution: consult the vitals faculty, then delegate to PyAutoHands | `bin/pyauto-brain build` | diff --git a/agents/_common.sh b/agents/_common.sh index 27c7f996..625f6832 100755 --- a/agents/_common.sh +++ b/agents/_common.sh @@ -69,8 +69,8 @@ _resolve_dir() { resolve_mind() { _resolve_dir PYAUTO_MIND PyAutoMind; } # resolve_cortex — locate the PyAutoCortex checkout (the organism's science -# state: phases, gates, runs, rulings of record). Resolved independently of the -# Mind so a session holding one organ and not the other still works. +# state: one ledger per project — Now, Runs, Log). Resolved independently of +# the Mind so a session holding one organ and not the other still works. resolve_cortex() { _resolve_dir PYAUTO_CORTEX PyAutoCortex; } # resolve_memory — locate the PyAutoMemory checkout (the organism's long-term diff --git a/agents/conductors/batch/_batch.py b/agents/conductors/batch/_batch.py index a2abed57..dd5f7fee 100644 --- a/agents/conductors/batch/_batch.py +++ b/agents/conductors/batch/_batch.py @@ -2689,7 +2689,7 @@ def read_review(text: str) -> dict: #: The packet's opening line. One organ since 2026-09-03: the science board and #: everything that modelled the human as a reviewer working a scheduled shift #: were retired (PyAutoCortex#9), and checking in on the science is -#: `pyauto-brain cortex collect` instead. +#: `pyauto-brain cortex checkin` instead. DEV_LEDE = ("{n} of {total} ended member(s) delivered on the evidence — a PR " "with a non-empty diff and checks that ran.") diff --git a/agents/conductors/batch/_status.py b/agents/conductors/batch/_status.py index 47c9ae6c..7a02572f 100644 --- a/agents/conductors/batch/_status.py +++ b/agents/conductors/batch/_status.py @@ -20,7 +20,7 @@ It rendered a second box for the Cortex until 2026-09-03, when the science review slot was retired (PyAutoCortex#9); checking in on the science is -`pyauto-brain cortex collect` now, and that surface has no board of its own. +`pyauto-brain cortex checkin` now, and that surface has no board of its own. """ from __future__ import annotations diff --git a/agents/conductors/cortex/AGENTS.md b/agents/conductors/cortex/AGENTS.md index 28e72c18..f46780d8 100644 --- a/agents/conductors/cortex/AGENTS.md +++ b/agents/conductors/cortex/AGENTS.md @@ -1,39 +1,41 @@ # Cortex agent > **Tier: conductor** — a front-door agent you *drive*. The *learning -> function* — where the organism finds out what is true: it reasons over -> PyAutoCortex (the science body map, the pre-registered tasks, the rulings -> of record) and answers one question — *where is my science?* — with one -> command, `checkin`: pull every active project, score every live run, move -> what came back, re-render the board, push the ledger, summarise by project. -> Its door **never submits a run and never writes a ruling**: a run is -> submitted only on the human's ask (by the human, or by the agent in the -> session through the project's own sync CLI), the verdict is the human's -> word, and the ruling file is the Cortex script's to write. +> function* — where the organism keeps track of what is true: it reasons over +> PyAutoCortex (the science body map and **one ledger per project**) and +> answers one question — *where is my science?* — with one command, +> `checkin`: pull every active project through its own sync CLI, show where +> each run stands, re-render the board, push the ledger, read it back by +> project. It **records cluster facts and the human's words, never a verdict +> of its own**: it never scores a result, never drafts a ruling, never writes +> a `result` or `lesson` entry the human did not say. A run is submitted only +> on the human's ask (by the agent in the session, through the project's own +> sync CLI), and every ledger write is a `scripts/cortex.py` verb. The same split the organism already uses twice — **Heart ↔ vitals**, **Gut ↔ -hygiene**: the organ keeps the state, the conductor reasons over it. The -Cortex holds runs and rulings the way the Mind holds prompts and PRs; this is -the Cortex's intake-and-dashboard conductor. +hygiene**: the organ keeps the state, the conductor reasons over it. A ledger +is `projects/.md`: `## Now` (2–3 lines the human rewrites — what is +running, what they meant to do next), `## Runs` (the jobs on the cluster right +now, `open | running`; a finished run leaves the list and becomes a log +entry), `## Log` (dated entries, newest first, kind `run | result | lesson | +note`). ## Verbs | Verb | Question | Emits | |------|----------|-------| -| `checkin [--dry-run \| --apply] [--push \| --no-push] [--project KEY] [--skip-pull] [--refreshed ISO]` | **Where is my science?** | the door — the sequence below, ending in a summary keyed by project; exit **1** when a pull failed or the tree needs a look | -| `census` | What is the Cortex holding? | task counts by state, the board's section counts, rulings, projects, the last check-in stamp (`--json` for the lot) | +| `checkin [--dry-run \| --apply] [--push \| --no-push] [--project KEY] [--skip-pull]` | **Where is my science?** | the door — the sequence below, ending in a summary keyed by project; exit **1** when a pull failed or the tree does not check | +| `census [--json]` | What is the Cortex holding? | per project: status, summary, runs by state, log length, last update; totals (active projects, runs open, runs running); the check-in stamp; the problems `cortex.py check` would report | | `dashboard --check` | Are the committed pages current? | exit 0 current · **1 stale** · 2 no checkout · 3 unreadable tree | | `dashboard --apply` | — | writes `dashboard.md` + `dashboard.html` | -| `gates` | What is each gated task waiting on? | every gated task, its refs and the URL each resolves to — read-only and offline | -| `collect [--pull] [--refreshed ISO] [--apply] [--out F] [--task REL]` | What came back, and is it worth reviewing? | one block per task — six scored legs, the readout, a blank ruling line — and exit **1** when any is not HEALTHY. **Default scope: every `submitted \| running` task**; `--task REL` narrows | +| `issue [--project KEY] [--apply]` | What sits at the top of each project's issue? | the fenced ledger block (`cortex.py`'s `issue_block`) per project with an `Issue:`; `--apply` writes it into the issue body through `gh` (replacing the block between the markers, or prepending it); never creates an issue; exit **1** without `gh` | ``` -pyauto-brain cortex checkin --dry-run # what it would pull and score +pyauto-brain cortex checkin --dry-run # what it would pull; reaches nothing pyauto-brain cortex checkin --apply # the check-in pyauto-brain cortex # census pyauto-brain cortex dashboard --apply -pyauto-brain cortex gates -pyauto-brain cortex collect --pull --apply # the scorer on its own +pyauto-brain cortex issue --apply pyauto-brain cortex --cortex # another checkout ``` @@ -47,156 +49,94 @@ Mind's: a session holding one organ and not the other still works. ## What it reads, and what it refuses to read - `/scripts/cortex.py` is imported at runtime and is the schema - API: `load_tasks`, `load_rulings`, `load_projects`, `gates_report`, - `move_task`. The conductor always reasons with the schema - the checkout it is pointed at implements. -- **Stdlib only, and Mind-free.** The renderer runs bare inside the Cortex's - own `dashboard_refresh.yml`, which installs nothing and checks out no - PyAutoMind — so `_cortex.py` imports neither `_sizing` nor `_intake` (both - hard-fail without a Mind checkout). The Mind's renderer helpers are copied, - not imported; that duplication is the price of a one-repo render. + API: `load_projects`, `load_ledgers`, `check_problems`, `issue_block`, + `issue_url`, the `Ledger` / `Run` / `Entry` objects. The conductor always + reads the schema the checkout it is pointed at implements. +- **Stdlib only (plus PyYAML through the Cortex script), and Mind-free.** The + renderer runs bare inside the Cortex's own `dashboard_refresh.yml`, which + checks out no PyAutoMind — so `_cortex.py` imports neither `_sizing` nor + `_intake` (both hard-fail without a Mind checkout). - **No path is named in this code.** Science projects live outside the workspace; the one place carrying such a path is the Cortex's own `projects.yaml`, and every path the board prints is read from a row of it. - **The assistant is a name, not a page.** `assistant` is a `projects.yaml` - field rendered by name into the work briefs; the conductor never resolves + field rendered by name into the resume prompt; the conductor never resolves it on disk and never reads an assistant page. +- **It never infers from a result.** No results file, log or witness is read + for a verdict. The only cluster output it shows is the project's own + `jobs` verb, printed verbatim. ## The board -The page opens on the door, not on the work: a counts table (what -`board/_board.py` reads for the Brain board's Cortex strip), then the +The page opens on the door: a counts table (`Running`, `Open`, `Projects` — +what `board/_board.py` reads for the Brain board's Cortex strip), the **check-in chip** — the paste for the laptop's science chat — and the **last -check-in** stamp under it. Then **Summary** (one row per active project — -its next task by that task's own summary), then **Projects** (active → -planned → dormant; each card is the folders, the counts and **every open -task of the project, one line each**: the ten-word `Summary:` as the link, a -state pill coloured by `STATE_TONES` — green planned/ready/accepted, yellow -submitted/running/pulled/awaiting-ruling, grey gated, **red** whenever a run -failed, timed out or was voided — and only the facets that state earns) → -**Awaiting ruling** (ordered failures → a ruling is required → clean) → -**Recent rulings**. - -The `Running / submitted`, `Ready` and `Gated` sections were dropped on -2026-09-07, with the "N more open phase(s)" fold: they said again, in three -more places, what the Projects block now says once, per project, in colour. -The census still cuts those buckets — they are `collect`'s and the door's -scopes — they are simply not sections of the page. Paths render as accent -chips (`.pathchip`, `--accent` fill with the theme's `--accent-ink`), not as -pink-on-tint inline code. - -No `## Where to look` bullets ride on the page — they stay in the task file, -in `census --by-project` and in the check-in printout, which keep the full -per-task tree. The Cortex has no epics of its own (retired 2026-09-04): a -science project *is* the long programme, and `Epic:` on a task header is -only an optional join key to a **Mind** epic (Mind epics really are -sequential; a Cortex task is not — that is why the number went). - -**`checkin.yaml`** is the one-key file (`refreshed: `) that -`cmd_checkin` and `collect --apply` write from the stamp they scored against, -before rendering. `census()` reads it into `c["checkin"]`; missing means -"never checked in", unparseable is a `problems` line. The stamp means *last -check-in*, never last render, so a doc-only push cannot fake freshness, and -the HTML twin computes its age on the **viewer's** clock (a static page -cannot know when it is read) and reddens it past sixty minutes. +check-in** stamp under it. Then **Summary**: one row per active project, four +narrow columns (`Project | Running | Open | Last update`) so it fits a phone. +Then **Projects**: a `### — ` card per project with a ledger — +active first in `projects.yaml` order, then planned/dormant, with the retired +ones folded into one `N retired` list at the end. Each card is a muted facts +line (status · partition · the issue or "no issue yet" · the ledger · local +path · RAL root), **Now** verbatim, **Runs** one line each (`ident — state — +partition — date — what`, clipped at 160 chars; "nothing on the cluster" when +empty), **Last 5** log entries (clipped at 240 chars) with a link to the full +log, and — for an active project — ONE 📋 chip, **resume ``**: read the +ledger, then the project's own `ledger` file from its row, then the +assistant's `AGENTS.md` when the row names one; "tell me where I left off and +what I said I would do next; submit nothing and log nothing until I say." +Dormant rows with no ledger sit in one small `No ledger` table. No retire +chips anywhere — retiring is `scripts/cortex.py retire`, a typed verb. + +**`checkin.yaml`** is the one-key file (`refreshed: `) the +door writes before rendering. `census()` reads it into `c["checkin"]`; +missing means "never checked in", unparseable is a `problems` line. The +stamp means *last check-in*, never last render, and the HTML twin computes +its age on the **viewer's** clock and reddens it once stale. `--check` compares the pages with the generation comment **and** the visible -`Last updated` banner stripped, so a re-render on a new date is not drift — -the Mind's normaliser strips only the comment, which is why its refresh -workflow self-heals with an empty commit most nights. `checkin.yaml` needs no -rule of its own: it is stable between renders. - -## Gates - -`gates` is a thin wrapper over the Cortex script's own `gates_report(root)`: -every gated task, its refs and the URL each ref resolves to. Nothing polls -GitHub and nothing flips a state — gate grading was retired on 2026-09-03 (2 -gated refs, 0 flips in its lifetime; sequencing is prose `Ready when:` lines -per Cortex schema decision 54). A human opens the refs and, when they have -closed, types `python3 scripts/cortex.py move ready`. +`Last updated` banner stripped, so a re-render on a new date is not drift. ## The door (`checkin`) The verb a human types. It composes what is already here and reasons nothing -extra of its own: +of its own: 1. **Sync.** Every project with `status: active` in `projects.yaml`, plus any - project that owns a task in `submitted | running` (a dormant project with a - job still out there is still out there). Each is pulled with **its own** - `/ pull` — the verb all seven implement — and the - 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 the door writes `/.cortex/pull.json` - (`project`, `pulled_at`, `cmd`, `rc`, `tasks_live`) — **merged** into - whatever is already there, because one project's own CLI writes the richer - `checkpoints` / `runs` tables the scorer's checkpoint leg reads. -2. **Score + move.** `collect`'s scorer over every live task, then the same - rehearsed `_apply_checked` moves. -3. **Render.** `dashboard.md` + `dashboard.html`. + project whose ledger lists a run (a dormant project with a job still out + there is still out there). Each is pulled with **its own** + `/ pull`, output **streamed**, not captured. A + non-zero exit is recorded against that project and the sweep continues. +2. **Jobs.** Where the row has a `jobs` verb and the ledger lists runs, the + project's own ` jobs` is run and its output printed **verbatim** + — no parsing, no state flip. The human, or the agent in the session, + records what it says with `cortex.py running | done`. +3. **Stamp + render.** `checkin.yaml`, then `dashboard.md` + `dashboard.html`. 4. **Push** (the rule below). 5. **Summarise, by project** — printed **last**, so a chat sees it above the - fold: each project's paths, what its pull did, its task counts, and every - task a human could act on today with its health verdict and the fenced, - copy-ready prompt its state already has (`_ruling_payload`, - `_live_payload`, `_ready_payload`, `_gate_payload`). `project_digest()` - builds one project's block and `checkin_summary()` the whole thing. + fold: `key — summary`, what the pull did, the jobs output (or "no jobs + verb"), Now, the runs, the last five entries, and a fenced block of the + three `cortex.py` lines most likely typed next (`done`, `log --kind + result|lesson`, `now`). -`--dry-run` (the default) prints the exact pull command per project, the pull -root, and every task it would score — and reaches nothing at all. `--project -KEY` narrows the sweep; `--skip-pull` re-scores what is already on the laptop, -stamping the refresh from the newest manifest. +`--dry-run` (the default) prints the exact `cd && +pull` per project and reaches nothing at all. `--project KEY` narrows the +sweep; `--skip-pull` skips the pull and still asks `jobs`, stamps and renders. ### 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, because -"clean" stops being true the moment the tasks move. That is the whole -cloud/laptop split, and it is also the default: a laptop pushes without asking, -a cloud session cannot and says so. The push cuts +checkout is clean on `main`** — read *before* anything is written. That is the +whole cloud/laptop split, and it is also the default: a laptop pushes without +asking, a cloud session cannot and says so. The push cuts `claude/checkin-` from a fresh `origin/main`, commits the changed paths **explicitly**, pushes, and names `ledger_merge.yml` as what lands it. `scripts/ledger_merge.py classify` is asked first and a code-classified diff is refused before the branch is cut. Never `main`, never `--force`, and a same-day re-check-in reuses its branch rather than resetting a pushed ref. -## The check-in (`collect`) - -This is the verb the human actually drives: *what came back?* With no -`--task` it scopes to **every task in `submitted | running`** — the runs the -Cortex believes are out there — and needs no record of any kind. `--task REL` -(repeatable) narrows it to named tasks. Each is scored against **six legs**, -each `PASS | FAIL | UNOBSERVABLE`: - -| Leg | Read from | -|-----|-----------| -| `err` | every `error.*.err` under the roots. Benign = every non-blank line is a `*Warning*` line or its indented continuation — **not** size 0; `Traceback`/`Error`/`Killed`/`OOM` ⇒ FAIL | -| `wall` | the `.out`'s first and last date stamps when it ends `Finished.`, else `Time To Run` in `search.summary` — **from the `.zip` when there is one**, because an extracted run dir can be a stale partial. Over `Budget:` ⇒ FAIL | -| `version` | a top-level `version` key in a JSON matching the project's `witness_file` | -| `checkpoint` | `/.cortex/pull.json` only (`{"schema": 1, "pulled_at": ISO, "checkpoints": {"": {"bytes": N, "mtime": ISO}}, "runs": {"": {"checkpoint_bytes": N, "checkpoint_mtime": ISO}}}`; looked up `runs[]` → `runs[]` → `checkpoints[]`, and a manifest with no `schema` is the older `runs`-only shape) — `search_internal/checkpoint.hdf5` is never pulled, so without that manifest the leg is UNOBSERVABLE, tagged `RAL only` | -| `resume` | `Fit Already Completed` / `Resuming … previous samples found` in the `.out` ⇒ FAIL: those are the previous fit's numbers | -| `witness` | a file matching `witness_file` newer than the task's first submission | - -HEALTH is **FAILED** if any leg failed, **SUSPECT** if any is unobservable, -**HEALTHY** otherwise; `delivered:` counts the HEALTHY ones. Two of the four -`delivered:` legs the batch records were scored on are simply not visible on -the laptop today — inventing PASS for them would be inventing evidence and FAIL would -condemn every healthy run, so they are UNOBSERVABLE and the member goes to the -human as SUSPECT. - -Everything is read from the laptop tree the human's own sync CLI filled; the -search roots are the project's `mirror` then `local_path`, from -`projects.yaml`. **The only thing that reaches the cluster is `--pull`**, which -runs that project's own ` pull` and prints the command first. -`--apply` (which needs a refresh stamp, from `--pull` or `--refreshed `, -so a human cannot move tasks on a stale laptop) moves each task -`running → pulled → awaiting-ruling` — rehearsed on a throwaway copy of the -tree first and refused outright if `cortex.py check` would not pass afterwards. -Nothing else is written. A task whose run line is still live, or one still -`submitted` (no such edge), is left where it is with a note. - ## What it never does -Submits a job · writes or edits a ruling · reads `sacct` as health · touches -RAL · consults an autonomy cap · edits a task except through the Cortex -script's own `move`. +Submits a job · scores a result · writes a `result` or `lesson` the human did +not say · edits a ledger except through the Cortex script's own verbs · +creates an issue · touches RAL except through the project's own CLI · +consults an autonomy cap · arms a timer. diff --git a/agents/conductors/cortex/_cortex.py b/agents/conductors/cortex/_cortex.py index 4e9ddfc9..cf1084a6 100644 --- a/agents/conductors/cortex/_cortex.py +++ b/agents/conductors/cortex/_cortex.py @@ -1,55 +1,37 @@ #!/usr/bin/env python3 """agents/conductors/cortex/_cortex.py — core for the Cortex Agent. -The Cortex Agent is the *learning function* of PyAutoBrain: the conductor that -reasons over PyAutoCortex, the organ where the organism learns what is true. -The Cortex holds the state — science tasks, their pre-registered witnesses, -their runs and the rulings of record; this conductor holds the reasoning: it -renders the Cortex board, grades the gates, admits ready tasks into a laptop -slot and scores what a pull brought back into a packet member. Its verbs -**never submit** and never edit a ruling: a run is submitted only on the -human's ask (through the project's own sync CLI), the verdict is theirs, and -the `Ruling` line this verb emits is left blank for them. - -The same split as Heart ↔ vitals and Gut ↔ hygiene — the organ keeps the -state, the conductor reasons over it. +The Cortex Agent is the *learning function* of PyAutoBrain: the conductor +over PyAutoCortex, the organ where the organism keeps track of what is true. +The Cortex is **one ledger per science project** (`projects/.md`): a +`## Now` the human rewrites, the `## Runs` on the cluster right now, and a +dated `## Log`, newest first. This conductor renders that ledger as the +board, pulls every active project through its own sync CLI, shows where each +run stands, and reads the ledger back by project. It **records cluster facts +and the human's words, never a verdict of its own**: it never scores a +result, never drafts a ruling, never writes a `result` or `lesson` entry — +those are the human's words, written on their ask through the Cortex's own +`scripts/cortex.py`. The same split as Heart ↔ vitals and Gut ↔ hygiene. Three constraints shape this module: -- **Stdlib only, and Mind-free.** The Cortex renderer runs bare inside the - Cortex's own `dashboard_refresh.yml`, which installs nothing and checks out - no PyAutoMind. So this module imports neither `_sizing` nor `_intake` (both - hard-fail without a Mind checkout: `_sizing.py` reads the body map at - import). The renderer helpers the Mind's page uses are *copied* here rather - than imported, deliberately — the duplication is the price of a page that - renders with one repo checked out. -- **The Cortex script is the API.** `/scripts/cortex.py` is - stdlib-only, has no import-time side effects and exposes pure functions - (`load_tasks`, `load_rulings`, `load_projects`, `gates_report`, …). It is - imported at runtime from the resolved root, so this conductor always reasons - with the schema the checkout it is pointed at actually implements. -- **No path is named here.** Science projects live outside the workspace; the - one place that carries such a path is the Cortex's own `projects.yaml`, and - every path this module prints is read from a row of it at runtime. +- **Stdlib only (plus PyYAML through the Cortex script), and Mind-free.** The + renderer runs bare inside the Cortex's own `dashboard_refresh.yml`, which + checks out no PyAutoMind, so nothing from the Mind's conductors is imported. +- **The Cortex script is the API.** `/scripts/cortex.py` exposes + pure functions (`load_projects`, `load_ledgers`, `check_problems`, + `issue_block`, `issue_url`) and is imported at runtime from the resolved + root, so this conductor always reads the schema the checkout implements. +- **No path is named here.** Science projects live outside the workspace; + the one place that carries such a path is the Cortex's own `projects.yaml`, + and every path this module prints is read from a row of it at runtime. Verbs: `checkin [--dry-run|--apply] [--push|--no-push] [--project KEY] -[--skip-pull] [--refreshed ISO]` · `census [--json]` · -`dashboard --check|--apply` · `gates` · -`collect [--pull] [--refreshed ISO] [--apply] [--out F] [--task REL]`. - -`checkin` is **the door** — the one command behind "where is my science?": it -pulls every active project through that project's own sync CLI, scores every -`submitted | running` task, moves what came back, re-renders the board, -optionally pushes the ledger, and prints a summary keyed **by project** with -the copy-ready prompt each task's state already has. It composes the verbs -below and reasons nothing extra of its own. - -`collect` is the scorer it composes: with no `--task` it scopes to every task -in `submitted | running`. It needs no batch record — the review-slot apparatus -was retired 2026-09-03. +[--skip-pull]` (the door) · `census [--json]` · `dashboard --check|--apply` · +`issue [--project KEY] [--apply]`. Exit codes: 0 ok · 1 dashboard drift (the `dashboard_refresh.yml` contract), -and for `collect` a member the human must look at · 2 bad args / no Cortex +a failed pull, or a tree that does not check · 2 bad args / no Cortex checkout · 3 the Cortex tree could not be read. """ @@ -66,7 +48,6 @@ import subprocess import sys import tempfile -import zipfile from pathlib import Path BRAIN_HOME = Path(__file__).resolve().parents[3] @@ -90,7 +71,8 @@ # Exit codes — the `dashboard_refresh.yml` contract lives on these. RC_OK, RC_DRIFT, RC_USAGE, RC_UNREADABLE = 0, 1, 2, 3 -RECENT_RULINGS = 12 +#: How much of a run's `what` and a log entry's text a card shows. +RUN_CLIP, LOG_CLIP = 160, 240 class CortexUnavailable(Exception): @@ -121,15 +103,9 @@ def resolve_root(explicit: str | None = None) -> Path: def find_script(root: Path) -> Path | None: - """The `scripts/cortex.py` that governs the tree at `root`. - - A *data root* need not be a checkout: every verb in the Cortex's own - script takes `root: Path`, so a fixture tree (`tests/fixtures/skeleton`) - is a legitimate root with no `scripts/` of its own. So look in the root, - then in its ancestors (the checkout the fixture lives in), then in the - resolved checkout — the schema that reads a tree is the one shipped - beside it. - """ + """The `scripts/cortex.py` that governs the tree at `root`: in the root, + then its ancestors (a fixture tree lives inside its checkout), then the + resolved checkout — the schema that reads a tree is the one beside it.""" for candidate in (root, *root.resolve().parents): script = candidate / "scripts" / "cortex.py" if script.is_file(): @@ -139,13 +115,8 @@ def find_script(root: Path) -> Path | None: def load_cortex(root: Path): - """Import the Cortex's own schema module for the tree at `root`. - - Loaded by file location under a per-path module name so two checkouts can - be read in one process without the first import shadowing the second. The - script's directory also goes on `sys.path`, as the Cortex's own tooling - expects. - """ + """Import the Cortex's own schema module for the tree at `root`, under a + per-path module name so two checkouts can be read in one process.""" if not root.is_dir(): raise CortexUnavailable( f"no Cortex tree at {root}. Set PYAUTO_CORTEX, clone " @@ -176,27 +147,22 @@ def load_cortex(root: Path): def _home(root: Path) -> str: """`https://github.com//` for this checkout, `''` if unknown. - The renderer must produce byte-identical pages on a laptop and inside the - Cortex's own refresh workflow, or `--check` would report permanent drift - and the self-heal would commit a page every night. So the owner is read - from a **file that travels with the repo** — its own README/AGENTS links, - the same declared surface the Mind's renderer reads out of `repos.yaml` — - and only falls back to the git remote, which is not guaranteed readable in - every CI container. No org is named here; a fork's Cortex carries its own. + Read from a file that travels with the repo (its own README/AGENTS links) + so a laptop and the refresh workflow render byte-identical pages; the git + remote is only the fallback. No org is named here. """ for name in ("README.md", "AGENTS.md"): f = root / name if f.is_file(): - m = OWNER_IN_DOCS.search(f.read_text(encoding="utf-8", - errors="replace")) + m = OWNER_IN_DOCS.search(_read(f)) if m: return f"https://github.com/{m.group(1)}/{CORTEX_REPO}" return _home_from_git(root) def _home_from_git(root: Path) -> str: - """The fallback: the checkout's own `origin`. The toplevel guard keeps a - fixture tree *inside* another repo from borrowing that repo's remote.""" + """The fallback: the checkout's own `origin` (toplevel-guarded so a fixture + inside another repo does not borrow its remote).""" try: top = subprocess.run(["git", "-C", str(root), "rev-parse", "--show-toplevel"], capture_output=True, @@ -218,29 +184,18 @@ def _home_from_git(root: Path) -> str: return f"https://github.com/{m.group(1)}/{m.group(2)}" if m else "" -# ------------------------------------------------------------- the census --- -# Task states, grouped into the buckets the census keeps. `live`, `ready` and -# `gated` stopped being sections of their own on 2026-09-07 — every open task -# of a project is a line on that project's card, which is the one place the -# reader looks — but they are still the scopes `collect` and the check-in -# door work in, so the census still cuts them. -AWAITING_STATES = ("pulled", "awaiting-ruling") -LIVE_STATES = ("submitted", "running") -FAILED_RUN_STATES = ("failed", "timeout", "void", "legacy_wrong") - -# One section: (key, title, source path in the repo, blurb). -SECTIONS = ( - # No blurb: the section is the map, and the cards say what they are. - ("projects", "Projects", "projects.yaml", ""), - ("awaiting", "Awaiting ruling", "tasks/", - "Results are in and nothing is running — the human's verdict is the only " - "thing outstanding. Ordered failures first, then the tasks a ruling is " - "required for, then the clean ones."), - ("rulings", "Recent rulings", "rulings/", - "The ledger of record, newest first. A verdict recorded only outside the " - "Cortex does not exist."), -) +def _read(path: Path) -> str: + try: + return path.read_text(encoding="utf-8", errors="replace") + except OSError: + return "" + +def _utc_now() -> str: + return _dt.datetime.now(_dt.timezone.utc).strftime("%Y-%m-%dT%H:%MZ") + + +# --------------------------------------------------------------- check-in --- #: The one-key file the check-in door writes and this page reads back. It #: means *last check-in*, not last render: a doc-only push re-renders the #: board and must not be able to fake freshness. @@ -256,13 +211,8 @@ def _home_from_git(root: Path) -> str: def read_checkin(root: Path) -> tuple[str, list[str]]: - """`(stamp, problems)` from `/checkin.yaml`. - - Missing is not a problem: a Cortex nobody has checked in yet is a state - the page can say out loud. A file that IS there but carries no readable - `refreshed:` is — something wrote it, and a stamp that cannot be parsed - cannot be trusted to mean anything. - """ + """`(stamp, problems)` from `/checkin.yaml`. Missing is not a + problem (never checked in); a file with no readable `refreshed:` is.""" path = root / CHECKIN_FILE if not path.is_file(): return "", [] @@ -275,159 +225,113 @@ def read_checkin(root: Path) -> tuple[str, list[str]]: def write_checkin(root: Path, stamp: str) -> Path: - """Persist the refresh stamp, before the pages are rendered: the board is + """Persist the refresh stamp before the pages are rendered: the board is meant to show the check-in that produced it, and `push_ledger` picks the - file up in the same commit as the task moves.""" + file up in the same commit.""" path = root / CHECKIN_FILE path.write_text(f"refreshed: {stamp}\n", encoding="utf-8") return path -def _mins(value: str) -> int | None: - """`H+:MM` → minutes, or None.""" - m = re.fullmatch(r"(\d+):(\d{2})", (value or "").strip()) - return int(m.group(1)) * 60 + int(m.group(2)) if m else None - - -def _int(value: str) -> int | None: - v = (value or "").strip() - return int(v) if v.isdigit() else None - - -def _where_bullets(mod, tk) -> list[str]: - """The task's own `## Where to look` bullets, `- ` stripped, verbatim. - - A task names where its results are. The by-project view renders this - text as the "which folder do I open" answer and `where_paths` resolves - the same bullets to paths — one reading, two uses. - """ - getter = getattr(mod, "_where_to_look", None) - if getter is not None: - bullets = getter(tk) - else: # a checkout whose script predates the helper - span = mod.sections(tk.text).get("Where to look") - bullets = ([ln for ln in tk.text.split("\n")[span[0]:span[1]] - if ln.startswith("- ") and ln.strip() != "-"] - if span else []) - return [b[2:].strip() for b in bullets if b[2:].strip()] - - -def _task_census_row(mod, tk) -> dict: - refs, bad_refs = mod.gate_refs(tk.get("Gates")) - runs = [{"ident": r.ident, "state": r.state, "partition": r.partition, - "date": r.date, "wall": r.wall, "note": r.note} - for r in tk.runs] - walls = [_mins(r["wall"]) or 0 for r in runs] - budget = tk.get("Budget") - return { - "rel": tk.rel, - "slug": tk.slug, - "title": tk.title or tk.slug, - # The board's line: the question this task answers, in at most ten - # words. Required by the Cortex's own `check`; the title is the - # fallback for a checkout that predates the header. - "summary": tk.get("Summary") or tk.title or tk.slug, - "project": tk.get("Project") or tk.project_dir, - "state": tk.state, - "gates": refs, - "bad_gates": bad_refs, - "witness": tk.get("Witness"), - "where": _where_bullets(mod, tk), - "budget": budget, - "budget_minutes": _mins(budget), - "runs": runs, - "wall_minutes": max(walls) if walls else 0, - "ruling": tk.get("Ruling"), - "epic": tk.get("Epic"), - "review_minutes": _int(tk.get("Review-minutes")), - "failed_runs": [r["ident"] for r in runs - if r["state"] in FAILED_RUN_STATES], - } +# ----------------------------------------------------------------- census --- +STATUS_RANK = {"active": 0, "planned": 1, "dormant": 2, "retired": 3} -def _ruling_row(mod, r) -> dict: +def _ledger_dict(mod, led, row: dict) -> dict: + issue = led.issue return { - "id": r.id, - "rel": r.rel, - "title": (r.title or r.id).split(" — ", 1)[-1] if r.title else r.id, - "verb": r.get("Ruling"), - "task": r.get("Task"), - "project": r.get("Project"), - "batch": r.get("Batch"), - "reviewed_at": r.get("Reviewed-at"), - "supersedes": r.get("Supersedes"), + "key": led.key, + "rel": led.rel, + "summary": led.summary, + "issue": issue, + "issue_url": mod.issue_url(issue) if issue != "none" else "", + "status": row.get("status", ""), + "partition": row.get("partition", ""), + "local_path": row.get("local_path", ""), + "ral_root": row.get("ral_root", ""), + "now": led.now, + "runs": [{"ident": r.ident, "state": r.state, "partition": r.partition, + "date": r.date, "what": r.text()} for r in led.runs], + "log": [{"date": e.date, "kind": e.kind, "text": e.text()} + for e in led.log], + "updated": led.updated(), + "n_log": len(led.log), } def census(root: Path) -> dict: - """Everything the board, the plan and the counts need, in one read.""" + """Everything the board and the check-in need, in one read: the rows of + `projects.yaml`, one dict per ledger, the counts, the stamp, the + problems `cortex.py check` would report.""" mod = load_cortex(root) - projects, project_problems = mod.load_projects(root) - tasks, task_problems = mod.load_tasks(root) - rulings, ruling_problems = mod.load_rulings(root) + projects, _ = mod.load_projects(root) + ledgers, _ = mod.load_ledgers(root) checkin, checkin_problems = read_checkin(root) - - rows = [_task_census_row(mod, tk) for tk in tasks] - by_state: dict[str, int] = {} - for r in rows: - by_state[r["state"] or "?"] = by_state.get(r["state"] or "?", 0) + 1 - - # A ruling that another ruling supersedes is not the standing verdict. - successors = {r.get("Supersedes") for r in rulings if r.get("Supersedes")} - ruling_rows = [_ruling_row(mod, r) for r in rulings] - for row in ruling_rows: - row["head"] = row["id"] not in successors - ruling_rows.sort(key=lambda r: r["id"], reverse=True) - - awaiting = [r for r in rows if r["state"] in AWAITING_STATES] - # failures → a ruling is required → clean, per the section's own promise. - awaiting.sort(key=lambda r: (0 if r["failed_runs"] else - 1 if r["state"] == "awaiting-ruling" else 2, - r["project"], r["rel"])) - live = sorted([r for r in rows if r["state"] in LIVE_STATES], - key=lambda r: (r["project"], r["rel"])) - ready = sorted([r for r in rows if r["state"] == "ready"], - key=lambda r: (r["review_minutes"] or 999, r["project"], - r["rel"])) - gated = sorted([r for r in rows if r["state"] == "gated"], - key=lambda r: (r["project"], r["rel"])) - # Not a board section — `planned` is the tail of the by-project tree, the - # "and then what" a check-in reads after everything open. - planned = sorted([r for r in rows if r["state"] == "planned"], - key=lambda r: (r["project"], r["rel"])) - - home = _home(root) + problems = mod.check_problems(root) + checkin_problems + rows = [_ledger_dict(mod, led, projects.get(led.key, {})) for led in ledgers] + # projects.yaml order within a status, active first. + order = {key: i for i, key in enumerate(projects)} + rows.sort(key=lambda d: (STATUS_RANK.get(d["status"], 9), + order.get(d["key"], len(order)), d["key"])) + counts = { + "running": sum(1 for d in rows for r in d["runs"] if r["state"] == "running"), + "open": sum(1 for d in rows for r in d["runs"] if r["state"] == "open"), + "active": sum(1 for row in projects.values() if row.get("status") == "active"), + } return { "root": str(root), - "home": home, + "home": _home(root), "generated": _dt.date.today().isoformat(), - "tasks": rows, - "by_state": by_state, - "awaiting": awaiting, - "live": live, - "ready": ready, - "gated": gated, - "planned": planned, - "rulings": ruling_rows, - "projects": projects, "checkin": checkin, - "problems": (project_problems + task_problems + ruling_problems - + checkin_problems), + "problems": problems, + "projects": projects, + "ledgers": rows, + "counts": counts, } -def section_counts(c: dict) -> list[tuple[str, str, int]]: - """`(key, title, count)` for the counts table — the verdicts owed and the - ruling ledger. `board/_board.py` reads this table.""" - sizes = {"awaiting": len(c["awaiting"]), "rulings": len(c["rulings"])} - return [(key, title, sizes[key]) for key, title, _src, _blurb in SECTIONS - if key in sizes] +def ledger_of(c: dict, key: str) -> dict | None: + for d in c["ledgers"]: + if d["key"] == key: + return d + return None + + +def active_ledgers(c: dict) -> list[dict]: + return [d for d in c["ledgers"] if d["status"] == "active"] + + +def no_ledger_rows(c: dict) -> list[tuple[str, dict]]: + """Rows of `projects.yaml` with no `projects/.md` at all.""" + have = {d["key"] for d in c["ledgers"]} + return [(k, row) for k, row in c["projects"].items() if k not in have] + + +def emit_census(c: dict) -> None: + n = c["counts"] + print("== Cortex census ==") + print(f"Root: {c['root']}") + print(f"Projects: {len(c['projects'])} in projects.yaml · " + f"{n['active']} active · {len(c['ledgers'])} with a ledger") + print(f"Runs: {n['running']} running · {n['open']} open") + print(f"Last check-in: {c['checkin'] or CHECKIN_NEVER}") + for d in c["ledgers"]: + runs = " · ".join(f"{r['ident']} {r['state']}" for r in d["runs"]) or "no runs" + print(f" {d['key']:<24} {d['status']:<8} {runs} · {d['n_log']} entries" + f" · updated {d['updated'] or '-'}") + if c["problems"]: + print(f"Problems: {len(c['problems'])} — run " + "`python3 scripts/cortex.py check`") + for p in c["problems"][:10]: + print(f" - {p}") + + +# ------------------------------------------------------------ the chips --- +def _clip(text: str, n: int) -> str: + text = " ".join((text or "").split()) + return text if len(text) <= n else text[:n - 1].rstrip() + "…" -# --------------------------------------------------------- render helpers --- -# Copied from the Mind's renderer rather than imported: `_intake.py` cannot be -# imported without a PyAutoMind checkout, and this page renders with only the -# Cortex and the Brain present. def _cell(value: str) -> str: return str(value).replace("|", "\\|") @@ -438,36 +342,17 @@ def _attr(value: str) -> str: .replace("<", "<").replace(">", ">")) -def _summary_label(value: str) -> str: - """Text rendered inside a `` — HTML, not markdown.""" - value = str(value).replace("", "").strip() - value = _html.escape(value, quote=False) or "Untitled" - return re.sub(r"`([^`]+)`", r"\1", value) - +def _esc(value: str) -> str: + """Text content for the HTML page.""" + return _html.escape(str(value), quote=False) -def _md_inline(text: str) -> str: - """The two inline markdown constructs this module authors, as HTML.""" - text = re.sub(r"`([^`]+)`", r"\1", text) - return re.sub(r"\*\*([^*]+)\*\*", r"\1", text) def _task_row(summary: str, payload: str) -> str: - """One row as a collapsed `
` whose 📋 summary IS the line and + """One 📋 row as a collapsed `
` whose summary IS the line and whose body is the fenced payload GitHub renders a copy button on.""" - return "\n".join([f"
📋 {summary}", - "", - "```", - payload, - "```", - "", - "
"]) - - -def _items(chunks: list) -> list: - out = [] - for chunk in chunks: - out += [chunk, ""] - return out[:-1] if out else [] + return "\n".join([f"
📋 {summary}", "", "```", + payload, "```", "", "
"]) def _html_task(text_html: str, payload: str) -> str: @@ -484,12 +369,8 @@ def _pages_url(home: str) -> str: def _board_links(home: str, current: str) -> list: - """The cross-board footer nav, from PyAutoBrain's declared config surface - (`config/policy.yaml` `board: boards:`), skipping this page's own entry. - - Stdlib regex on the one-pair-per-line block, not yaml — this renderer - runs bare in the Cortex's refresh workflow, which installs nothing. - """ + """The cross-board footer nav from `config/policy.yaml` `board: boards:`, + skipping this page's own entry — a stdlib regex, as the renderer runs bare.""" m = re.match(r"https://github\.com/([^/]+)/", home or "") policy = BRAIN_HOME / "config" / "policy.yaml" if not m or not policy.is_file(): @@ -504,723 +385,185 @@ def _board_links(home: str, current: str) -> list: for name, repo in pairs if name != current] -def _anchor(title: str) -> str: - """GitHub's heading anchor for a section title.""" - slug = re.sub(r"[^a-z0-9 -]", "", title.lower()) - return slug.replace(" ", "-") - - -def _src_url(blob: str, src: str) -> str: - """The GitHub URL of a section's source — `tree` for a directory.""" - if not blob: - return src - return (blob.replace("/blob/main/", "/tree/main/") + src) if src.endswith("/") \ - else blob + src - - -# ------------------------------------------------------------- the payloads --- -# Every row hands the reader the next command rather than a decision. The -# science verbs stay the Cortex script's and a run is only ever the human's ask. -def _work_brief(r: dict, projects: dict) -> str: - """The entry protocol for the subagent that works this task, or `""`. - - A project row names the domain assistant its work enters through; this - renders that name into the three work-shaped payloads. The conductor - NAMES the assistant and never reads it — no stat, no resolve, no - assistant page loaded in the Cortex chat (see this conductor's - AGENTS.md). A row without the field, or with `none`, gets no brief: the - work is plain workspace work. - """ - row = projects.get(r["project"], {}) - assistant = row.get("assistant", "none") - if not assistant or assistant == "none": - return "" - env = re.sub(r"[^A-Za-z0-9]", "_", assistant).upper() - return "\n".join([ - f"Work brief — {r['project']} / {r['slug']}. Delegate this to an " - "execution-tier subagent; never work it in the Cortex chat.", - f"cd {row.get('local_path', '')} && source activate.sh", - f"Enter through the assistant `{assistant}`: resolve it as ${env}, " - f"else /{assistant}; read its AGENTS.md first and " - "follow its constitution.", - "Then read wiki/project/state.md, the newest " - "wiki/project/YYYY-MM-DD-*.md, and the skills the task names.", - f"Then the task {r['rel']} — its ## Witness is the contract.", - "Finish: write today's journal entry, rewrite wiki/project/state.md, " - "and return (1) the outcome against the witness and (2) assistant " - "drift — any skill or wiki page that was wrong, missing or stale.", - ]) - - -def _with_brief(payload: str, r: dict, projects: dict) -> str: - """`payload` with the work brief under it, separated by a blank line — - or `payload` unchanged when the project declares no assistant.""" - brief = _work_brief(r, projects) - return f"{payload}\n\n{brief}" if brief else payload - - -def _checkin_payload(c: dict) -> str: - """The paste for the laptop's science chat — the whole door as one - sentence, naming the stamp it is refreshing *from* so "since last time" - needs no second explanation.""" - since = c.get("checkin") or "never" +def checkin_payload(c: dict) -> str: return (f"/cortex — check in on every active science project since the " - f"last check-in ({since}): pull each project through its sync " - "CLI, score every live run against its pre-registered witness, " - "move what came back, re-render and push the board, then read me " - "the by-project summary with the prompt each task needs next.") - - -def _retire_payload(key: str) -> str: - """The paste that ends a project — the whole retirement as one sentence. - - It names the project twice on purpose: once in the prose, so a chat that - reads the sentence aloud says which project is being ended, and once - inside the command, so the command is runnable without re-reading the - sentence. Retiring keeps the row, the tasks and the rulings; only the - status and the note change, and the ledger has to be pushed afterwards or - the board goes stale.""" - return (f"/cortex — retire the science project {key}: confirm it is " - f"holding nothing live, then in PyAutoCortex run `python3 " - f"scripts/cortex.py retire {key} --why \"\"`, " - f"`python3 scripts/cortex.py check`, `pyauto-brain cortex " - f"dashboard --apply`, and push the ledger. The row, its tasks " - f"and its rulings all stay — only the status and the note change.") - - -def _retire_cell_html(key: str, c: dict) -> str: - """The Retire column of the Nothing-open table: a copy chip on a dormant - row, an empty cell on any other. A `planned` project has not started, so - it is not offered retirement.""" - if project_status(key, c) != "dormant": - return "" - return (f'') - - -def _ruling_payload(r: dict) -> str: - return (f"Review the PyAutoCortex task {r['rel']} and help me rule on it: " - f"read its `## Witness` and the pulled evidence under its " - f"`## Where to look`, score the witness, then draft the ruling " - f"body for my approval and run `python3 scripts/cortex.py rule " - f"{r['rel']} --body `.") - - -def _live_payload(r: dict, projects: dict) -> str: - row = projects.get(r["project"], {}) - cli, path = row.get("sync_cli", ""), row.get("local_path", "") - if cli and path and "jobs" in (row.get("sync_verbs") or []): - return f"cd {path} && {cli} jobs" - return (f"Report where the runs of the PyAutoCortex task {r['rel']} " - f"({', '.join(x['ident'] for x in r['runs']) or 'no runs'}) stand.") - - -def _submit_line(project: str, projects: dict) -> str: - """The project's own submit verb, as it would be typed at the laptop — or - the note that says the row has no such verb. Every path comes from the - row.""" - row = projects.get(project, {}) - cli, path = (row.get("sync_cli") or ""), (row.get("local_path") or "") - if cli and path and "submit" in (row.get("sync_verbs") or []): - return f"cd {path} && {cli} submit