Skip to content

fix: Cortex scorer drops relative Where-to-look, scores a stale run #370

Closed

Description

@Jammy2211

Overview

The Cortex check-in scorer cannot see runs written outside output/ — and
instead of saying so it scores the task against whatever is newest under
output/, manufacturing a confident FAIL from an unrelated run. This violates
the door's own stated contract that "UNOBSERVABLE is not FAIL". On the
2026-09-09 check-in, eight of nine live tasks came back FAILED and none was an
actually failed run: euclid_dr1_prelim's ordered_mge_witness_102005065 and
ordered_mge_control_unordered_102005065 were both scored against a stale
phase-4 vis_pix directory belonging to a different tile while their real
completed results sat in output_ordered_witness/, and three
subhalo_validation tasks were scored against that same wrong directory.

Three defects, all in PyAutoBrain/agents/conductors/cortex/_cortex.py:

  1. where_paths() keeps a bullet only if p.is_absolute(). Every real task
    writes its ## Where to look bullets relative to the project root, so the
    resolved list is always empty in practice.
  2. where_paths() takes only bullet.split()[0] as the candidate token. Real
    bullets lead with a project-row label — `euclid_dr1_prelim` (project row): `output_ordered_witness/run_0/…` — so the first token is never the
    path.
  3. run_artifacts() does bases = list(where) or [r / "output" …]. With
    where empty it silently scores a stale, unrelated run directory, with no
    signal to the reader that this is not the task's run.

The test fixture tests/_cortex_board.py writes absolute ## Where to look bullets, which is why the suite never caught any of this.

Plan

  • Scan the whole ## Where to look bullet for path-like tokens (backticked
    spans, plus bare words containing /) instead of only its first token, so a
    bullet that leads with a project-row label still yields its path.
  • Resolve a relative bullet against each of the project's roots (the mirror,
    then local_path) rather than discarding it for not being absolute.
  • When a task declares paths and none of them resolve, report no run at all
    rather than falling back to output/ — the run-dependent legs then read
    UNOBSERVABLE and the task scores SUSPECT, not FAILED.
  • When the scorer does fall back (a task that names no path), say so on the run
    line in the readout and in the wall leg, so a wall figure read from another
    run is never presented as the task's own.
  • Cover all three with regression tests against the existing board fixture.
Detailed implementation plan

Affected Repositories

  • PyAutoBrain (primary)

Branch Survey

Repository Current Branch Dirty?
./PyAutoBrain main (2 behind origin) clean

No worktree claim conflict (worktree_check_conflict cortex-scorer-where-paths PyAutoBrain → 0).

Suggested branch: feature/cortex-scorer-where-paths

Implementation Steps

  1. New _path_tokens(bullet) beside where_paths in _cortex.py.
    Candidates, in reading order, deduped: every backtick-delimited span (the
    way task authors mark a path), then every whitespace token of what is left
    that contains /. Drop a candidate containing whitespace, ://, or a ..
    component (no escaping the root); strip trailing .,;:. A project-row label
    such as `euclid_dr1_prelim` survives tokenising but is dropped by the
    existence check in step 2.

  2. where_paths(mod, tk, roots) — for each token: absolute → keep if
    _under() a root and exists (today's rule, unchanged); relative → try
    root / token for every root from project_roots(row), keeping each that
    exists. Both roots may legitimately hold the same relative path; keep both.

  3. run_artifacts(roots, where, since, declared) — returns a 3-tuple
    (run_dir, zip_path, source) and takes declared (did the task name any
    path-like token at all):

    task declares resolves result
    paths yes bases = where, source="where"
    paths no (None, None, "unresolved") — no fallback
    nothing — bases = output/ dirs, source="fallback"

    run_dir is None already sends leg_wall and leg_checkpoint to
    UNOBSERVABLE, so a task with no discoverable run scores SUSPECT rather than
    FAILED. Also register a base that is itself a .zip, which today's dir-only
    walk misses.

  4. Say so in the readout. score_task() carries run_source and the
    unresolved declared tokens; member_block()'s "Where to look yourself"
    section marks a fallback run line as a fallback, and on unresolved names
    the declared paths that do not exist instead of printing another run's dir.
    leg_wall() gains fallback: bool = False and says so when the minutes came
    from search.summary (a wall figure read from the task's own .out is
    unaffected).

  5. Regression tests in tests/test_cortex_conductor.py, on the existing
    board fixture and _score() helper, each rewriting one task's ## Where to look section (the re.sub idiom already used by
    test_a_task_that_names_nowhere_still_renders):

    • a relative bullet carrying a project-row label prefix still finds
      <mirror>/output/searches/bright/aaaa1111 and the wall leg PASSes (fails
      on today's code);
    • declared paths that do not exist give run_dir is None, wall and
      checkpoint UNOBSERVABLE, health not FAILED, and a member block that names
      the missing path rather than another run's dir;
    • a task naming no path still gets a fallback run, and both the member block
      and the wall leg mark it as a fallback.

Key Files

  • PyAutoBrain/agents/conductors/cortex/_cortex.py — _path_tokens (new),
    where_paths, run_artifacts, leg_wall, score_task, member_block.
  • PyAutoBrain/tests/test_cortex_conductor.py — the three regression tests.
  • PyAutoBrain/tests/_cortex_board.py — read-only here; its absolute where
    bullets are what hid the bug.

Verification

python -m pytest PyAutoBrain/tests/test_cortex_conductor.py PyAutoBrain/tests/test_batch_kinds.py -q (the board fixture is shared), then a
dry pyauto-brain cortex checkin (no --apply) to confirm the real
euclid_dr1_prelim / subhalo_validation tasks stop scoring against the stale
phase-4 vis_pix directory.

Out of scope (adjacent, known — file separately)

  • void in FAILED_RUN_STATES counting a deliberately cancelled job as failed.
  • find_logs() globbing every historical run stem, so leg_resume reads an old
    job's .out.
  • The pull side (custom output roots are never pulled from) — its own draft,
    draft/bug/pyautobrain/custom_output_roots_are_never_pulled_from.md.

Original Prompt

Click to expand starting prompt

Cortex scorer blind to runs outside output/ and fails them against…

Type: bug
Target: PyAutoBrain
Repos:

  • PyAutoBrain
    Difficulty: medium
    Autonomy: safe
    Priority: high
    Status: formalised
    Consequence: notify
    Witness: a task whose "## Where to look" bullets name a relative path outside output/ is scored against that path, and a task with no discoverable run scores UNOBSERVABLE rather than FAIL; both covered by regression tests.
    Review-minutes: 0
    Unattended: ready

Cortex scorer blind to runs outside output/ and fails them against an unrelated run

Type: bug
Target: PyAutoBrain
Witness: a task whose "## Where to look" bullets name a relative path outside output/ is scored against that path, and a task with no discoverable run scores UNOBSERVABLE rather than FAIL; both covered by regression tests.

Science runs increasingly write to a custom PYAUTO_OUTPUT_DIR rather than output/. The Cortex check-in scorer cannot see those runs at all, and instead of saying so it scores the task against whatever is newest under output/ — manufacturing a confident FAIL from an unrelated run. This violates the door's own stated contract that "UNOBSERVABLE is not FAIL".

In PyAutoBrain/agents/conductors/cortex/_cortex.py:

  1. where_paths() (~line 1640) resolves a task's "## Where to look" bullets but keeps a bullet only if p.is_absolute(). Every task writes these bullets relative to the project root (e.g. output_ordered_witness/run_0/...), so the resolved list is always empty in practice.

  2. where_paths() also takes only bullet.split()[0] as the candidate path token. Real bullets lead with a project-row label, e.g. "euclid_dr1_prelim (project row): output_ordered_witness/run_0/...", so the first token is not a path and the real path is never examined.

  3. run_artifacts() (~line 1666) then does bases = list(where) or [r / "output" ...] and picks the newest .completed marker or zip under output/. With where empty this scores a stale, unrelated run directory with no signal to the reader that the run being scored is not the task's run.

Observed on the 2026-09-09 check-in: euclid_dr1_prelim tasks ordered_mge_witness_102005065 and ordered_mge_control_unordered_102005065 both scored "witness FAIL" against a stale phase-4 vis_pix directory belonging to a different tile, while their real completed results sat in output_ordered_witness/. Three subhalo_validation tasks were scored against that same wrong directory. Eight of nine live tasks came back FAILED; none was an actually failed run.

Wanted:
(a) resolve relative Where-to-look bullets against the project root;
(b) scan the whole bullet for path-like tokens rather than only the first;
(c) when a task declares roots and they yield no run, report UNOBSERVABLE instead of falling back to output/ and scoring whatever is newest. Any fallback that changes which run is being scored must say so in the readout rather than presenting the result as the task's own run.

Activity

  1. Jammy2211 commented on Sep 9, 2026

    @Jammy2211
    ContributorAuthor

    Library PR opened: #371

    Test evidence: full suite 939 passed / 1 failed in 6:12 (the one failure is a pre-existing worktree/symlink trap, unrelated to this change, and passes in the canonical checkout / CI). Ship-step re-run of the touched file (tests/test_cortex_conductor.py): 93 passed, 1 failed (same known trap). Three new regression tests added, all fail against the pre-fix module.

    Heart is RED on five reasons, acknowledged by the human in-session as organism-scope (PyAutoMind/active.md heart-ack: line). Stopping at PR-open per policy — merge stays human.

  2. Jammy2211 commented on Sep 9, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    Merged in #371 (ec354a7).

    What shipped — three defects in agents/conductors/cortex/_cortex.py:

    • where_paths now resolves relative ## Where to look bullets against the project's registered roots instead of discarding them.
    • where_paths scans the whole bullet for path-like tokens rather than only bullet.split()[0], so label-prefixed bullets are seen.
    • run_artifacts no longer silently falls back to the newest run under output/ when a task's declared paths do not resolve — that state is UNOBSERVABLE, not a substitution, and any fallback that does still happen is labelled as one in both readouts.

    CI — Brain Tests green on 9f46175: pytest (3.12) and pytest (3.13) both success.

    Field evidence for the bug this fixes: on the 2026-09-09 check-in, eight of nine live tasks came back FAILED and not one was a failed run. Three subhalo_validation tasks and both euclid_dr1_prelim ordered-MGE tasks were scored against the same stale phase-4 vis_pix directory belonging to a different tile, while their real completed results sat in output_ordered_witness/.

    Not covered by this fix — the sibling gap is that a custom PYAUTO_OUTPUT_DIR is never pulled to the laptop in the first place: each science project's hpc/sync carries its own hard-coded PULL_DIRS (three divergent forks: (output output_sed inspect), (output results), (output)), and both pull and pull-full iterate it. Filed separately as draft/bug/pyautobrain/custom_output_roots_are_never_pulled_from.md.

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