Skip to content

OpenConceptLab/ocl_online#549 | rebuild_expansion_version_lists takes a release over HEAD recorded beside another release - #1135

Open
paynejd wants to merge 6 commits into
masterfrom
version-lists-head-last
Open

paynejd wants to merge 6 commits into
masterfrom
version-lists-head-last

Conversation

@paynejd

@paynejd paynejd commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

For OpenConceptLab/ocl_online#549. The command is from OpenConceptLab/ocl_issues#3005 (#1030).

In short: rebuild_expansion_version_lists could record a source's HEAD beside an older release. The older release then decided what a release made from the collection holds, so members that were added to the source after that release were left out, also when a newer release has them. With this change the command records the newer release.

What went wrong

A collection's HEAD has c1, from v2, which v3 has too, and c2, which was added to the source after v2 and is in v3. Its expansion recorded v2 and the source's HEAD. Neither reference names a version.

  1. The command looked for a recorded version that holds each reference's members. For c2 that was HEAD, which holds everything current, so it never looked at v3. It recorded HEAD and v2 as evaluated.
  2. A build reads one evaluated version of a source, the one with the highest id: v2. A lock on HEAD loses to nearly any release.
  3. A release made from the collection with its versions copied ("Copy HEAD's parameters") had c1 and no c2.

The command itself never changes a member. The loss came later, with the next release.

Versions recorded A release made from it
Before this change HEAD, v2 c1
With it v3 c1, c2

The change

The lists settle as before. If a source's HEAD is then left beside a release of it, the rebuild goes on with HEAD last for that source:

  • Each reference without a version records a live release that holds all its members. If several do, it's the one that holds the most members of all those references together, so a release made from the collection changes as little as possible. On a tie the version recorded now stays, then the newest wins.
  • A member that is the source's own current row counts for the release that holds its latest version, as the content is the same.
  • A member that only HEAD holds still records HEAD, as before. No release has it, so a release made from the collection can't either.
  • HEAD as the only version recorded stays. No release can stand in for it there, and the next add still finds what the source has now.
  • References to value sets go as before. The command judges each of them on its own, so a value set's HEAD can still be recorded beside a release of it, when one value set is used twice without a version and its members came from two versions.

If you ran the command before this change

Run it again, with the options you used then. The new step starts from the settled lists, and those are what the first run left, so you get what one run with this change gives. Run backfill_expansion_health after it, as after the first one.

It doesn't repair a release that was made in between. Make that one again, or compare it with the collection's HEAD.

Tests

  • 14 new tests in tests_version_lists.py, each of which also checks that a second run changes nothing. Eight fail without the change. The other six keep what should stay: HEAD as the only version, HEAD beside a release that nothing uses, the lock on a tie, a draft that another reference names, and members that no release holds, also when the collection's owner can't view the source's HEAD.
  • tests_version_lists, tests_reference_conversions and tests_health pass (212), and pylint is clean.
  • The table above is from the command, and then a release, run on a local server with both rules.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qWkLnjsCZJ8jUFU5Vd

paynejd and others added 2 commits December 4, 2026 11:01
… a release over HEAD recorded beside another release

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWkLnjsCZJ8jUFU5Vd
…release gives way to the release closest to the members

Codex, pass 1: the choice reads what the rebuild itself ends with, not a release the old list still had; and of the
releases holding a reference's members it takes the one holding the most members of them all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWkLnjsCZJ8jUFU5Vd
@paynejd

paynejd commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 1 (codex-cli 0.169.0, commit 39c9ba1)

Verdict: findings, 2 finding(s).

  • F1.1 (P1, core/collections/version_lists.py:106): An older explicit pin can take the place of a mixed evaluated HEAD and prevent the rebuild from selecting the newest live release.
  • F1.2 (P2, core/collections/version_lists.py:104): An unused release left in the old list can turn a HEAD-only evaluation into a release lock.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "full",
  "commit": "39c9ba19b",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "F1.1",
      "severity": "P1",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 106,
      "claim": "An older explicit pin can take the place of a mixed evaluated HEAD and prevent the rebuild from selecting the newest live release.",
      "scenario": "The evaluated list contains HEAD and v2, and a separate versioned reference pins v3 explicitly. Of two versionless references, c1 is held by v2 and v4, while c2 is held by HEAD, v3, and v4. The rebuild promotes v3 for c2 and settles on {v2, v3}. The next locked build uses v3 and drops c1 even though v4 holds both members.",
      "action": "When a reference would pick HEAD alongside an evaluated release, try the newest visible live release that holds all its members before falling through to a lower-priority recorded pin. Cover the mixed explicit and evaluated case for sources and value sets.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F1.2",
      "severity": "P2",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 104,
      "claim": "An unused release left in the old list can turn a HEAD-only evaluation into a release lock.",
      "scenario": "After the only reference using v2 is removed, the old evaluated list still contains {HEAD, v2}. The remaining reference's member is held by HEAD and v3. The base rebuild drops unused v2 and keeps HEAD. This change instead pins v3, so a subsequent versionless add can miss members added to HEAD after v3.",
      "action": "Base the HEAD demotion on whether the current references would actually record a release beside HEAD. Add a regression test with an unused release in the old evaluated list.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Reply to pass 1, in 2c262d5:

  • F1.1 (P1): fixed, a little differently. The newest release would have its own bad case: it can change members that an earlier one still holds as they are. So of the releases that hold all of a reference's members, it now takes the one that holds the most members of all the repository's references without a version. In the scenario that's v4, which holds both. When a release right after the recorded one holds everything, it's that one. Two tests.
  • F1.2 (P2): fixed. The choice no longer looks at the list it was given. The rebuild first settles as before, and only then, if HEAD is left beside a release that a reference uses, it goes on with HEAD last. A release nobody uses is dropped first, and HEAD stays. One test.

So a second run on lists that an earlier version of the command left gives what one run with this change gives: both start from the same settled lists. MAX_PASSES is 8 for the extra round. Notes that later passes repeated are kept once.

…es replaces HEAD beside a release

Codex, pass 2: includes and excludes are counted together, a newer lock doesn't come back when the references settle, and
a version another reference names, retired or not, doesn't come before the live releases. HEAD's own rows count for the
release that holds their latest version, and on a tie the lock stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWkLnjsCZJ8jUFU5Vd
@paynejd

paynejd commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 2 (codex-cli 0.169.0, commit 2c262d5)

Verdict: findings, 4 finding(s).

  • F1.1: unresolved.
  • F1.2: resolved.
  • F2.1 (P1, core/collections/version_lists.py:449): Source settling can restore a newer lock that the coverage ranking correctly displaced.
  • F2.2 (P1, core/collections/version_lists.py:529): F1.1 still occurs for value sets because the first eligible recorded version wins without comparing coverage.
  • F2.3 (P1, core/collections/version_lists.py:418): Source release scoring counts includes and excludes separately, so a release covering both can lose.
  • F2.4 (P2, core/collections/version_lists.py:105): An explicitly pinned retired version can take the evaluated lock even when a live release holds the same members.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "2c262d569",
  "verdict": "findings",
  "prior": [
    {
      "id": "F1.1",
      "status": "unresolved"
    },
    {
      "id": "F1.2",
      "status": "resolved"
    }
  ],
  "findings": [
    {
      "id": "F2.1",
      "severity": "P1",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 449,
      "claim": "Source settling can restore a newer lock that the coverage ranking correctly displaced.",
      "scenario": "The evaluated list is {HEAD, v4}. Version v4 holds c1, HEAD holds c2, and v3 holds both. The coverage ranking picks v3 for both references, but settling moves c1 back to v4 because v4 was already evaluated and is newer. The rebuild writes {v3, v4}, so the next locked build uses v4 and loses c2.",
      "action": "Honor the coverage ranking during settling for repositories with mixed HEAD and release locks. Add a regression test where the best release is older than the existing lock.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.2",
      "severity": "P1",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 529,
      "claim": "F1.1 still occurs for value sets because the first eligible recorded version wins without comparing coverage.",
      "scenario": "Two version-less value-set references contribute c1 and c2. The evaluated list is {HEAD, v2}, and a separate reference explicitly pins v3. Version v2 holds c1, HEAD and v3 hold c2, and v4 holds both. The rebuild settles on {v2, v3}. The next locked build uses v3 for both version-less references and loses c1.",
      "action": "Rank value-set releases by coverage across all version-less references to that value set. Add a regression test with the separate explicit pin.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.3",
      "severity": "P1",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 418,
      "claim": "Source release scoring counts includes and excludes separately, so a release covering both can lose.",
      "scenario": "The evaluated list is {HEAD, v2}. One reference includes c1, which v2 and v3 hold. Another excludes c2, which HEAD, v3, and v4 hold. The include group picks recorded v2 and the exclude group picks newest v4. The next locked build uses v4 and loses c1 even though v3 holds both members.",
      "action": "Compute one coverage score per release across the source's version-less includes and excludes, then use that score when choosing each reference's holder.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F2.4",
      "severity": "P2",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 105,
      "claim": "An explicitly pinned retired version can take the evaluated lock even when a live release holds the same members.",
      "scenario": "The evaluated list is {HEAD, v2}, with c1 held by v2 and c2 held by HEAD. A separate reference explicitly pins retired v4. Live v3 and retired v4 both hold c1 and c2. Their coverage scores tie, and v4 comes first because it was recorded. The rebuild makes v4 the evaluated lock.",
      "action": "Restrict HEAD replacement to active, released, non-retired versions, including when considering versions already recorded. Preserve the separate explicit pin.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Reply to pass 2, in b6a5132. The four findings had one cause, so one change answers them: once HEAD goes last for a source, its live releases are ranked once, by how many members of all its references without a version each one holds.

  • F2.1 (P1): fixed. The references then settle on their picks alone, so a newer lock that holds less doesn't come back.
  • F2.2 (P1): fixed. A version that another reference names no longer comes before the live releases, for value sets too. Value sets aren't ranked: each reference takes the version it has now if that still holds its members, else the newest release that does.
  • F2.3 (P1): fixed. Includes and excludes are counted together.
  • F2.4 (P2): fixed. Recorded versions that aren't live releases come after the live ones, and the reference that names one keeps it.

Two things I added, from trying the rule on more cases. On a tie the lock stays, so the next add doesn't move to a newer release for nothing. And a member that is the source's own current row counts for the release that holds its latest version, as the content is the same. Ten of the 15 new tests fail without the change, and each one also checks that a second run changes nothing.

…t live releases, and value sets stay as they were

Codex, pass 3: a draft or a retired version that another reference names no longer replaces HEAD. Value sets are out of
this change: each reference to one is judged on its own, without the step that settles a source's references.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qWkLnjsCZJ8jUFU5Vd
@paynejd

paynejd commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 3 (codex-cli 0.169.0, commit b6a5132)

Verdict: findings, 4 finding(s).

  • F1.1: resolved.
  • F1.2: resolved.
  • F2.1: unresolved.
  • F2.2: unresolved.
  • F2.3: resolved.
  • F2.4: resolved.
  • F3.1 (P1, core/collections/version_lists.py:122): Value-set releases receive no coverage score, so the rebuild can choose a newer release that drops a member.
  • F3.2 (P1, core/collections/version_lists.py:480): Source settling can discard the coverage-ranked release when another reference picks a newer release.
  • F3.3 (P2, core/collections/version_lists.py:109): A recorded draft can replace HEAD for a reference whose member is absent from every release.
  • F3.4 (P2, core/collections/version_lists.py:256): The command can mark value-set lists settled even though a second run rewrites them.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "verify",
  "commit": "b6a513243",
  "verdict": "findings",
  "prior": [
    {
      "id": "F1.1",
      "status": "resolved"
    },
    {
      "id": "F1.2",
      "status": "resolved"
    },
    {
      "id": "F2.1",
      "status": "unresolved"
    },
    {
      "id": "F2.2",
      "status": "unresolved"
    },
    {
      "id": "F2.3",
      "status": "resolved"
    },
    {
      "id": "F2.4",
      "status": "resolved"
    }
  ],
  "findings": [
    {
      "id": "F3.1",
      "severity": "P1",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 122,
      "claim": "Value-set releases receive no coverage score, so the rebuild can choose a newer release that drops a member.",
      "scenario": "Two versionless value-set references contribute c1 and c2. The evaluated list is {HEAD, v2}. Version v2 holds c1, HEAD and v4 hold c2, and v3 holds both. The rebuild keeps v2 for c1 and picks v4 for c2. The next locked build uses v4 for both references and loses c1.",
      "action": "Rank live value-set releases by coverage across all versionless references to that value set. Test an older release that holds both members against a newer release that holds only one.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.2",
      "severity": "P1",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 480,
      "claim": "Source settling can discard the coverage-ranked release when another reference picks a newer release.",
      "scenario": "The evaluated list is {HEAD, v4}. Three versionless references contribute c1, c2, and {c3, c4, c5}. HEAD holds c2 through c5, v3 holds c1, c3, and c4, and v4 holds c1 and c2. The coverage pass picks v3 for c1, v4 for c2, and HEAD for the third reference. Settling sorts those picks by recency and moves c1 back to v4. The command reports {HEAD, v4} as settled and never records v3.",
      "action": "Preserve coverage-ranked choices during source settling. Add a regression test where another reference still needs the newer release.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.3",
      "severity": "P2",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 109,
      "claim": "A recorded draft can replace HEAD for a reference whose member is absent from every release.",
      "scenario": "The evaluated list is {HEAD, v2}, and a separate reference explicitly pins a newer draft. Version v2 holds c1. HEAD and the draft hold c2, which no release holds. The rebuild picks the draft for c2 before trying HEAD and writes {v2, draft}. A locked build then uses the draft and loses c1 if the draft lacks it.",
      "action": "Try HEAD before recorded non-live versions when no live release holds the reference's members. Preserve the separate explicit draft pin.",
      "lines_delta": null,
      "confidence": "high"
    },
    {
      "id": "F3.4",
      "severity": "P2",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 256,
      "claim": "The command can mark value-set lists settled even though a second run rewrites them.",
      "scenario": "Four versionless references to one value set contribute c1, c2, c3, and c4. The evaluated list is {HEAD, v1, v4}. HEAD holds c3, v1 holds c4, v2 holds c1, v3 holds c3, and retired v4 holds c1 and c2. The first run applies {v1, v2, v3, v4}. The second run starts with ordinary recorded-version ordering, picks v4 for c1, and removes v2. HEAD is already gone, so the coverage pass never runs again.",
      "action": "Verify stability using the candidate order a fresh invocation will use before marking the lists settled. Add a test that applies the first result and checks that the second run leaves it unchanged.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

@paynejd

paynejd commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Reply to pass 3, the last, in 64f78f2:

  • F3.1 (P1) and F3.4 (P2): value sets are out of this change. The command judges each reference to a value set on its own. It has no step that settles them together, as it has for a source's references, and both findings come from that. Adding one is more than this fix should carry. References to value sets now go exactly as before, so a HEAD recorded beside a release of one value set can still stay. It takes one value set used twice without a version, with members from two of its versions.
  • F3.2 (P1): not changed, as it has no effect. With v3 kept, the list would be {HEAD, v3, v4}, and a build reads the version with the highest id, which is v4 with or without v3. c2 needs v4, as no other release holds it. So settling only leaves out a version no build would read.
  • F3.3 (P2): fixed. HEAD is tried before recorded versions that aren't live releases, so a draft or a retired version that another reference names doesn't take its place. One test.

@paynejd

paynejd commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Simplification review (a fresh Claude subagent, commit 64f78f2): 3 possible cuts, 1 taken, in 2b2916b.

  • S2, a helper with one caller (get_candidates): cut. It's back in pick_versionless's own loop.
  • S1, the if repeats else set() guard in build: kept. HEAD may go last only once the lists have settled. That's what makes a second run, on lists an earlier version left, give the same as one run.
  • S3, merge the tests for a retired version and for a draft: kept apart. They pin different findings: a live release comes before a retired version (F2.4), and HEAD comes before a draft (F3.3). The two tests where HEAD stays differ too: in one HEAD is the only version, in the other it's beside a release.

@paynejd

paynejd commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits b6a5132..2b2916b (codex-cli 0.169.0, commit 2b2916b)

Verdict: findings, 1 finding(s).

  • FC.1 (P2, core/collections/version_lists.py:412): HEAD can now take precedence over an already-recorded live release that the visibility filter excludes from discovery.
findings.json
{
  "reviewer": "codex-cli 0.169.0",
  "perspective": "defects",
  "mode": "final",
  "commit": "2b2916b74",
  "verdict": "findings",
  "prior": [],
  "findings": [
    {
      "id": "FC.1",
      "severity": "P2",
      "tag": null,
      "file": "core/collections/version_lists.py",
      "line": 412,
      "claim": "HEAD can now take precedence over an already-recorded live release that the visibility filter excludes from discovery.",
      "scenario": "Two versionless references contribute c1 and c2. The evaluated list contains public HEAD and public v2, which holds only c1. A separate reference explicitly pins live v3 for c1. Version v3 is private to another organization and holds both members. The previous revision settled on v3. The new order tries HEAD before the recorded v3 and leaves {HEAD, v2}. A subsequent locked build by a user who can access v3 now uses v2 and drops c2.",
      "action": "Try already-recorded live releases before HEAD and keep drafts and retired versions after HEAD. Preserve the visibility filter for unrecorded releases and add a regression test for the private live pin.",
      "lines_delta": null,
      "confidence": "high"
    }
  ]
}

FC.1 (P2): accepted. It takes a reference that names another owner's private release. The command then records HEAD and v2, which is what it records on master too, so nothing gets worse. Trying that release first would lock the collection to a version its owner may not be able to view, and the next reference without a version would be read from it.

One commit came after this check, 7851662: it only wraps a docstring line.

@paynejd
paynejd marked this pull request as ready for review December 4, 2026 18:02
@paynejd
paynejd requested a review from snyaggarwal December 4, 2026 18:02

This branch has not been deployed

No deployments
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