Repository navigation
cortex: de-duplicate projects.yaml and reject duplicate project keys (#50) - #51
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
projects.yamlhad 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 retiredeuclid_sersicsrow).yaml.safe_loadsilently 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 makescortex.py checkreject 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,
## Nowrewrites, check-in notes) landed onmaindirectly as ledger commits; this PR is the code half.API Changes
None for library users.
cortex.py checkgains one new problem string:projects.yaml: duplicate project key '<key>' (lines a, b, …), raised from a raw column-0 key scan that runs beforeyaml.safe_loadinparse_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 -qin the worktree: 65 passedpython3 scripts/cortex.py check: OKtest_projects_yaml_rejects_duplicate_project_keysfails with the guard removed, passes with itduplicate project key 'analytic_gaussian' (lines 118, 292, 452)yaml.safe_loadkey set identical before and after (17 keys)scripts/ledger_merge.py classify --base origin/main: all 4 paths classified code (human review), as intendedpyauto-brain cortex dashboard --check: pages already current, no regeneration neededFull 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 numbersscripts/cortex.py::PROJECT_KEY_LINE_RE—^([a-z][a-z0-9_]*):\s*(#.*)?$Changed
scripts/cortex.py::parse_projectsseeds itsproblemslist from the duplicate scan beforeyaml.safe_loadprojects.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.yamlheader 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 existsGenerated by the PyAutoLabs agent workflow.
Heart RED override (development only)
cortex.py checkOK; ledger_merge classify → code (human review).🤖 Generated with Claude Code