Skip to content

fix: custom PYAUTO_OUTPUT_DIR roots are never pulled from the HPC #372

Closed

Description

@Jammy2211

Overview

Science runs increasingly write to a custom PYAUTO_OUTPUT_DIR (one output root
per arm, so parallel arms do not collide). Those roots are never pulled to the
laptop: each science project's hpc/sync carries a hard-coded PULL_DIRS array
that both pull and pull-full iterate. On 2026-09-09, euclid_dr1_prelim
jobs 342375_[0-1] (ordered MGE witness) and 342377_0 (unordered control)
completed on RAL and wrote 166 MB across three runs into
output_ordered_witness/; none of it came down, and retrieving it needed a
hand-edited copy of the project's own sync CLI.

Sibling task #370 / PR #371 makes such runs scorable once they are on the
laptop. This one makes them arrive.

This issue is blocked on #371 — it reuses the _path_tokens() helper that
PR adds, and the worktree conflict guard reports PyAutoBrain as claimed by that
task. Registered in PyAutoMind/planned.md until #371 merges.

Survey findings that shaped the design

  • 12 projects, 3 active. subhalo_validation, euclid_dr1_prelim,
    slope_hierarchy_scale. The other nine are dormant or retired.
  • The forks share one ancestor. 55–95% of each script is verbatim identical;
    inference_programme/hpc/sync:4-5 names the ancestor in prose. 11 of 12
    iterate a flat PULL_DIRS array identically; only the retired
    inference_programme differs structurally (parallel
    PULL_DIRS/PULL_DESTS/LOG_INDICES).
  • The override seam already exists. Every script sources a gitignored
    hpc/sync.conf, whose sync.conf.example says "You can also export these as
    environment variables instead of editing a file" — but only for HPC_HOST,
    HPC_BASE, PROJECT_NAME. PULL_DIRS=(…) is a bare literal below that
    source (sync.conf at line 55, PULL_DIRS at line 112 in
    euclid_dr1_prelim/hpc/sync), so it clobbers any override.
  • The pull verb is arg-blind. pull) pull ;; never forwards "$2",
    unlike submit/cancel/tail. A --dirs flag would need the dispatch line
    and pull()'s body changed in every fork; the env seam needs neither, and
    pull-full inherits it since it iterates the same array.

The safety constraint that shapes root selection

A pull rsyncs remote → local ("${REMOTE}/${dir}/" →
"${PROJECT_ROOT}/${dir}/"). Real tasks' ## Where to look bullets name
results/, wiki/project/state.md, scripts/…, hpc/batch_cpu/… — feeding
those to a pull would overwrite the human's own source with the cluster's copy.
So Cortex contributes only output*-shaped roots, and the script
appends them, never replaces. This is where the "glob output*" option from
the prompt actually lives: applied to declared paths inside Cortex, so no
remote enumeration is needed.

Plan

  • Cortex derives the output* roots its tasks declare (reusing _path_tokens()
    from cortex: check-in scorer resolves Where-to-look bullets against project roots #371) and passes them to each project's own pull through an
    environment variable — the same override convention hpc/sync.conf already
    documents.
  • The three active projects' hpc/sync honour that variable by appending
    the extra roots to their own PULL_DIRS, so a project's own roots always
    pull and an unset variable reproduces today's behaviour exactly.
  • The organ boundary is unchanged: Cortex still only runs the human's own CLI,
    never reaching RAL itself.
  • Nine dormant/retired projects are deliberately left alone; they pick the
    convention up when reactivated.
Detailed implementation plan

Affected Repositories

  • PyAutoBrain (primary)
  • euclid_strong_lens_modeling_pipeline
  • subhalo_validation (a PyAutoLabs repo, not in repos.yaml)
  • slope_hierarchy_scale (a PyAutoLabs repo, not in repos.yaml)

Branch Survey

Repository Current Branch Dirty?
./PyAutoBrain main clean — claimed by cortex-scorer-where-paths (#370)
./euclid_strong_lens_modeling_pipeline main clean
Science/subhalo_validation main 4 dirty (live science tree)
Science/slope_hierarchy_scale main 1 dirty (live science tree)
Science/euclid_dr1_prelim main 6 dirty, 2 commits ahead unpushed

Suggested branch: feature/cortex-pull-declared-output-roots

Implementation Steps

  1. PyAutoBrain — agents/conductors/cortex/_cortex.py.

    • PULL_DIRS_ENV = "PYAUTO_PULL_DIRS"; OUTPUT_ROOT_RE = ^output[\w.-]*$,
      with the remote→local hazard recorded as the reason for the guard.
    • declared_output_roots(mod, tasks) -> list[str] — first path segment of
      each relative declared token, kept only when it matches
      OUTPUT_ROOT_RE; deduped, sorted. Absolute tokens skipped.
    • pull_env(roots) → {**os.environ, PULL_DIRS_ENV: " ".join(roots)}, or
      None when there are no roots, so a project declaring nothing invokes
      exactly the command it does today.
    • Thread through both pull paths — run_pull() (used by collect) and
      run_pull_streamed() (used by checkin), which today call
      subprocess.run(..., cwd=…) with no env. Their callers (cmd_collect
      ~2121, the checkin ~2577) already have the tasks in scope.
    • pull_shell(row, roots) — what --dry-run prints — shows the assignment:
      cd <path> && PYAUTO_PULL_DIRS="output_ordered_witness" hpc/sync pull.
  2. The three sync CLIs. Identical additive block immediately after the
    PULL_DIRS=(…) literal, plus a documenting paragraph in each
    hpc/sync.conf.example:

    # Extra roots the caller asks for, space-separated — the Cortex check-in
    # passes the `output*` roots its tasks declare, so a run written to a custom
    # PYAUTO_OUTPUT_DIR is pulled without this list being edited by hand.
    # Appended, never replacing: this project's own roots always pull.
    if [[ -n "${PYAUTO_PULL_DIRS:-}" ]]; then
        for _extra in ${PYAUTO_PULL_DIRS}; do
            [[ " ${PULL_DIRS[*]} " == *" ${_extra} "* ]] || PULL_DIRS+=("${_extra}")
        done
    fi

    An env var cannot carry a bash array, hence the space-separated scalar; the
    unquoted expansion is deliberate (word-splitting is the parse) and is why
    Cortex only ever emits output* tokens.

  3. Routing per project.

    project repo route
    euclid_dr1_prelim euclid_strong_lens_modeling_pipeline — registered in repos.yaml; its hpc/sync is byte-identical (53fc4c66…) to the science clone's normal task worktree + PR
    subhalo_validation PyAutoLabs/subhalo_validation — real repo, unregistered git -C <clone> worktree add into the scratchpad, edit, push, PR
    slope_hierarchy_scale PyAutoLabs/slope_hierarchy_scale — same same

    All three science clones are live working trees on main with uncommitted
    science state. Nothing switches branches in them — the separate worktree
    exists precisely so the live trees are never disturbed; they pick the change
    up with an ordinary git pull once merged.

Key Files

  • PyAutoBrain/agents/conductors/cortex/_cortex.py — declared_output_roots,
    pull_env, PULL_DIRS_ENV, OUTPUT_ROOT_RE (new); run_pull,
    run_pull_streamed, pull_shell + their two callers (changed).
  • PyAutoBrain/tests/test_cortex_conductor.py — new tests.
  • <each project>/hpc/sync and <each project>/hpc/sync.conf.example.

Verification

Brain unit tests on the existing board fixture:

  1. declared_output_roots keeps output_ordered_witness from a real-shaped
    bullet and rejects results, wiki, scripts, hpc and absolute
    tokens — the remote→local hazard asserted directly.
  2. dedupe + sort across several tasks of one project.
  3. pull_shell() shows the PYAUTO_PULL_DIRS= assignment when roots exist and
    is byte-identical to today's string when none do.
  4. both pull paths pass the env: monkeypatch subprocess.run, assert the env
    carries PYAUTO_PULL_DIRS, and that it is absent for a project declaring no
    output* root.

Then the full PyAutoBrain/tests/ suite (~6 min; the one known
worktree-symlink failure passes in the canonical checkout and in CI).

Bash side: bash -n on each edited script, plus a harness sourcing only the
variable block with and without PYAUTO_PULL_DIRS set, asserting the resulting
PULL_DIRS — including that an already-present root is not duplicated.

Live witness (the prompt's own): euclid_dr1_prelim with
PYAUTO_PULL_DIRS=output_ordered_witness. output_ordered_witness/run_1/… is
already on the laptop, so the rsync is a near-no-op --update. This is the
only step that touches RAL and needs human confirmation first
, per the
supervised autonomy level.

Flagged, not fixed

  • euclid_dr1_prelim's science clone is 2 commits ahead of origin, unpushed —
    it will diverge from the merged change until those are pushed.
  • The retired inference_programme is structurally different and would need
    bespoke work.
  • The real root cause is 12 forks of one ancestor with no provenance marker.
    De-forking to a maintained template is the durable fix, out of scope here,
    and worth its own prompt.

Original Prompt

Click to expand starting prompt

Custom output roots are never pulled from the HPC — each project's…

Type: bug
Target: PyAutoBrain
Repos:

  • PyAutoBrain
  • PyAutoCortex
    Difficulty: large
    Autonomy: supervised
    Priority: normal
    Status: formalised
    Consequence: notify
    Witness: a science run written to a custom PYAUTO_OUTPUT_DIR is pulled to the laptop by the project's own sync CLI without that path being hand-added to a per-project array.
    Review-minutes: 0
    Unattended: ready

Custom output roots are never pulled from the HPC — each project's hpc/sync has its own static PULL_DIRS

Type: bug
Target: PyAutoBrain
Witness: a science run written to a custom PYAUTO_OUTPUT_DIR is pulled to the laptop by the project's own sync CLI without that path being hand-added to a per-project array.

Science runs increasingly write to a custom PYAUTO_OUTPUT_DIR (one output root per arm, so parallel arms do not collide). Those roots are never pulled to the laptop, because each science project's hpc/sync carries its own hard-coded PULL_DIRS array and both the pull and pull-full verbs iterate it.

Evidence from 2026-09-09:

  • euclid_dr1_prelim: PULL_DIRS=(output output_sed inspect)
  • subhalo_validation: PULL_DIRS=(output results)
  • slope_hierarchy_scale: PULL_DIRS=(output)
    Three different file hashes — these are divergent per-project forks, not copies of a shared template, so there is no single place to add a path.

Concrete miss: euclid_dr1_prelim jobs 342375_[0-1] (ordered MGE witness) and 342377_0 (unordered control) completed on RAL and wrote to output_ordered_witness/. 166MB across three completed runs sat unpulled; the Cortex check-in reported the tasks as FAILED. Retrieving them needed a temporary edited copy of the project's own sync CLI.

The human confirms splitting results into custom output folders will become commonplace, so a per-project path addition is not the fix.

Options to weigh (design decision wanted, not a predetermined answer):

  • glob output* in PULL_DIRS so any output root is pulled by convention;
  • have the pull consult the Cortex task ledger's declared output roots for that project;
  • give the sync CLI a flag the Cortex check-in can pass.

Filed against PyAutoBrain because the Cortex check-in door is what invokes each project's <sync_cli> pull and is the only place a general convention can be consulted centrally; part of this task is deciding whether the convention belongs there, in PyAutoCortex, or in the per-project science clones under the Science directory (which are not workspace repos).

Sibling task: the Cortex scorer bug filed alongside this one (scorer blind to runs outside output/) — that one makes such runs scorable once pulled; this one makes them arrive.

Activity

  1. Jammy2211 commented on Sep 9, 2026

    @Jammy2211
    ContributorAuthor

    Unblocked — the sibling #370 / PR #371 merged on 2026-09-09 (ec354a7), so the scorer half is in.

    That fix makes a run written to a custom PYAUTO_OUTPUT_DIR scorable once it is on the laptop: where_paths now resolves relative ## Where to look bullets against the project roots, and run_artifacts reports UNOBSERVABLE rather than silently scoring the newest unrelated run under output/.

    What is still open here is the other half — getting those roots to arrive. Nothing in #371 touches the pull, so a custom output root still has to be fetched by hand today.

    Field note for whoever picks this up: the three live science projects have genuinely divergent arrays, so there is no single file to edit —

    • euclid_dr1_prelim: PULL_DIRS=(output output_sed inspect)
    • subhalo_validation: PULL_DIRS=(output results)
    • slope_hierarchy_scale: PULL_DIRS=(output)

    Three different file hashes, no shared template. Both the pull and pull-full verbs iterate the same array, so neither verb can reach a custom root.

  2. Jammy2211 commented on Sep 9, 2026

    @Jammy2211
    ContributorAuthor

    Shipped across all four repos — commits, pushes, and PRs open. Awaiting merge (library-first: PyAutoBrain first).

    PRs:

    Commits:

    • PyAutoBrain 27be325
    • euclid_strong_lens_modeling_pipeline 6ffd2df
    • subhalo_validation 202e849
    • slope_hierarchy_scale 9572405

    Evidence recap:

    • Full PyAutoBrain/tests/ suite: 943 passed, 1 failed in 3:22 — the one failure is the known pre-existing worktree/symlink trap (test_a_fixture_tree_finds_the_schema_its_checkout_ships), passes in canonical checkout/CI.
    • Four new Cortex tests pass (only-output-shaped-roots guard, pooled/deduped roots, no-extra-root no-op, env-assignment seam).
    • bash -n clean on all three edited hpc/sync scripts.
    • Behavioural harness on all three scripts confirms exact-reproduction-when-unset, append-on-extra-root, no-duplication.
    • Live RAL dry-run witness against euclid_dr1_prelim: without the seam, output_ordered_witness/ never appears in the pull; with PYAUTO_PULL_DIRS=output_ordered_witness set, it is listed and not reported missing. rsync --dry-run --stats on that root: 115 files (90 regular, 25 dirs), 173,465,562 bytes sitting on RAL.

    Heart is RED on five organism-scope reasons, acknowledged in-session for this task (recorded in PyAutoMind/active.md); none of these four repos are in the release chain. Not merging — stopping at PR-open per policy.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01FKSwTBuNwcJc2FPNpSCrkp

  3. Jammy2211 commented on Sep 9, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    All four PRs merged.

    repo PR merge commit
    PyAutoBrain #373 11aa3f83
    euclid_strong_lens_modeling_pipeline #59 da9ff852
    subhalo_validation #1 ab4bf323
    slope_hierarchy_scale #1 be6e88da

    CI at merge: PyAutoBrain pytest (3.12) + (3.13) pass; euclid pipeline 9/9 legs pass across Tests and Smoke Tests. subhalo_validation and slope_hierarchy_scale have no workflows configured — merged on local evidence (bash -n plus the append/dedupe harness) after an explicit human decision. Heart freeze: not frozen.

    Live witness (RAL dry run, euclid_dr1_prelim). Without the seam the pull enumerated output/, output_sed/ (absent), inspect/ (absent) and never mentioned output_ordered_witness/. With PYAUTO_PULL_DIRS=output_ordered_witness that root appears and is not reported missing; rsync --dry-run --stats shows it holds 115 files (90 regular, 25 dirs), 173,465,562 bytes on RAL — the results the 2026-09-09 check-in could not see.

    Follow-ups, deliberately not in scope here: find_logs() globs every historical run stem so leg_resume reads an old job's .out, and void remains in FAILED_RUN_STATES. Those two are what still make the check-in read FAILED. De-forking the 12 hpc/sync scripts to a maintained template remains the durable fix for the root cause.

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