Skip to content

cortex: de-duplicate projects.yaml and reject duplicate project keys (#50) - #51

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/ep-checkin-cleanup
Sep 30, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/ep-checkin-cleanup

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Summary

projects.yaml had been tripled by 25e0168 (2026-09-17, the euclid_dr1 / euclid_sersics birth recovery): lines 292–610 repeated the 11 rows analytic_gaussian…autolens_inference twice more, byte-identical to the first copy (which alone also holds the retired euclid_sersics row). yaml.safe_load silently kept the last copy, so the parsed body map was unchanged but every edit had to be made three times and any divergence between copies would have been invisible. This PR drops the two copies (610 → 290 lines, 17 keys unchanged) and makes cortex.py check reject a repeated project key so it cannot recur.

Part of the 2026-09-30 EP check-in clean-up (PyAutoCortex#50). The ledger side of that task (seven stale runs closed, ## Now rewrites, check-in notes) landed on main directly as ledger commits; this PR is the code half.

API Changes

None for library users. cortex.py check gains one new problem string: projects.yaml: duplicate project key '<key>' (lines a, b, …), raised from a raw column-0 key scan that runs before yaml.safe_load in parse_projects. Validation continues after a duplicate (like the per-row problems); only invalid YAML / non-mapping documents still return early. REFERENCE.md "projects.yaml" states the one-row-per-key rule.

Test Plan

  • python -m pytest tests -q in the worktree: 65 passed
  • python3 scripts/cortex.py check: OK
  • New test_projects_yaml_rejects_duplicate_project_keys fails with the guard removed, passes with it
  • Guard run on the pre-fix 610-line file reports all 11 tripled keys, e.g. duplicate project key 'analytic_gaussian' (lines 118, 292, 452)
  • yaml.safe_load key set identical before and after (17 keys)
  • scripts/ledger_merge.py classify --base origin/main: all 4 paths classified code (human review), as intended
  • pyauto-brain cortex dashboard --check: pages already current, no regeneration needed
Full API Changes (for automation & release notes)

Added

  • scripts/cortex.py::_duplicate_key_problems(text) — raw column-0 key scan; returns one problem per repeated key with its line numbers
  • scripts/cortex.py::PROJECT_KEY_LINE_RE — ^([a-z][a-z0-9_]*):\s*(#.*)?$

Changed

  • scripts/cortex.py::parse_projects seeds its problems list from the duplicate scan before yaml.safe_load
  • projects.yaml — lines 292–610 removed (two byte-identical copies)
  • REFERENCE.md — one-row-per-key rule documented under "projects.yaml"

Follow-up (not in this PR)

  • projects.yaml header comment (lines 12–13) still says the file is parsed with the stdlib and points at a REFERENCE.md "restricted YAML subset" section that no longer exists

Generated by the PyAutoLabs agent workflow.

Heart RED override (development only)

  • Authorised by the live human in the Claude Code session at 2026-09-30 ~10:55 BST: "Override for all three (Recommended)" — RED override for PyAutoCortex#50 (push + open the pending-release PR) and for opening two PyAutoFit tasks; no merge, no release.
  • Exact RED reasons at the 10:51 BST tick: "PyAutoArray: 2 commit(s) behind origin"; "PyAutoLens: 2 commit(s) behind origin"; "release validation FAILED (stage integrate)".
  • Branch gates passed: pytest tests 65 passed; cortex.py check OK; ledger_merge classify → code (human review).
  • This PR does not claim to fix Heart. Heart remains RED for release purposes; merge needs its own human command and green required checks.

🤖 Generated with Claude Code

Jammy2211 and others added 2 commits September 30, 2026 10:57
…es introduced by 25e0168 (610 → 290 lines, 17 keys unchanged)

Lines 292-610 repeated the 11 rows analytic_gaussian..autolens_inference
twice more (identical to copy 1 except copy 1 also holds the retired
euclid_sersics row). yaml.safe_load kept the last copy, so the parsed
key set (17 projects) is unchanged. The trailing blank line left at 291
is dropped too, so the file is 290 lines ending in a single newline.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… guard + test + REFERENCE note)

yaml.safe_load silently keeps the last of a repeated mapping key, which is
how 25e0168 tripled 11 rows without `cortex.py check` noticing. parse_projects
now scans the raw column-0 keys before safe_load and reports each repeat as
`projects.yaml: duplicate project key 'X' (lines a, b, c)`; the rest of the
file is still validated (non-fatal, like the per-row problems). Run against
the pre-fix 610-line file it names all 11 tripled keys.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Sep 30, 2026
@Jammy2211
Jammy2211 merged commit 505907f into main Sep 30, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the feature/ep-checkin-cleanup branch September 30, 2026 13:52
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 7, 2026
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.

1 participant