Skip to content

Entry identity: reusable outputs in conda; warn on an uncertain first write - #621

Draft
guijacquemet wants to merge 2 commits into
mainfrom
claude/vibrant-maxwell-ktjhbd
Draft

guijacquemet wants to merge 2 commits into
mainfrom
claude/vibrant-maxwell-ktjhbd

Conversation

@guijacquemet

@guijacquemet guijacquemet commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Cause. In a fresh conda environment (Python 3.12) with every brick pip-installed from its release tag, an entry output was never reusable: the first fiberfeatures run published, then every rerun and every check of that output was refused with ENTRY_IDENTITY_UNCERTAIN: ... (setuptools: RECORD missing) ... Install a released fiberfeatures (not editable ...). Conda installs setuptools as an .egg-info with no RECORD. brick_identity follows every requirement of the brick, every extra included, and that walk reached setuptools, so every record written there was uncertain (ADR 0007 case (b)). This affects every brick's entry, not only fiberfeatures.

By module:

  • entry_identity: the installers pip, setuptools and wheel (INSTALL_TOOLS) are no longer listed or followed in the requirement closure. Any other library without a RECORD, or installed editable, still makes the identity uncertain. A name a brick passes explicitly in libraries is still identified, even an installer. New uncertain_library(brick) returns the library (name, version, why) behind an uncertain brick part, or None when the brick's own code is the cause.
  • entry_record: write_entry_record still writes a record whose identity is uncertain, but now also emits an EntryIdentityWarning saying the output will never be reused, with the reason and the fix. The text comes from the new identity_warning(record, output=None), which a brick can print with the published path. Both are re-exported from the package.
  • entry_errors: new uncertain_code_fix(brick, library=None). For the brick itself the fix is the ADR's text, unchanged. For an uncertain library the fix names that library, says why (no RECORD, with pip install --force-reinstall --no-deps "<name>==<version>"; or an editable install) and says the brick needs no change. entry_identity_uncertain(..., library=) and reuse_or_refuse use it.
  • Docs: contract §21.2 and §21.4, plan §12 question 93, the AGENTS.md map, and the CHANGELOG under Unreleased (v0.10.1).

Decisions

The smallest change ADR 0007 allows is to leave the installers out of the closure:

  • The ADR's identity covers "every library the brick may compute with". pip, setuptools and wheel install and build distributions; no brick computes a value with them.
  • Dropping extras would make the identity weaker than MorphoFeature's brick_cache key, which takes every extra; the ADR requires "at least as strong". It also would not fix the bug, because some libraries require setuptools with no extra (torch on Python ≥ 3.12).
  • Identifying an .egg-info by name and version would contradict ADR 0007 (b): a library without a RECORD is uncertain. Case (b) is kept for every other library.

For the owner:

  • The ADR's record paragraph should say that the installers are not followed. I can't write to the Spec from this session.
  • The ADR fixes one fix text for cases (a)–(c), naming the brick. The library-specific fix goes beyond that text, so the ADR may want to adopt it.

Notes for review

  • An output whose v0.10.0 record lists one of the installers counts as another identity under v0.10.1 (ENTRY_OUTPUT_EXISTS naming it). Upgrading preprocessing changes every brick's identity anyway, because preprocessing is one of each brick's libraries.

  • Leaving setuptools out also leaves out pkg_resources, which a few old libraries import at runtime. I judged that it does not compute values.

  • The warning is a Python warnings.warn, so a brick's CLI shows it on stderr unless the brick filters warnings. Bricks that want their own wording can print identity_warning(record, output).

  • Not verified: a real conda environment end to end with fiberfeatures (fiberfeatures is private and not reachable from this session). The conda case is simulated: fake .egg-info distributions in a temporary site folder, placed ahead of the real setuptools on sys.path.

  • Audit follow-ups (second commit): the warning now comes only after the record is written (it used to come before the exclusive open, so a refused write still said "written"). The editable-library fix now forces the reinstall, because a plain pip install "lib==1.0" over an editable 1.0 is skipped as already satisfied.

  • Every brick's own test suite will now see this warning. A brick's tests usually run from an editable install, whose identity is uncertain. If a brick's pytest settings turn warnings into errors (filterwarnings = error), its entry tests will fail until it filters EntryIdentityWarning or expects it. I could not check the bricks' settings from here.

  • The suggested pip command is not verified on a real conda package. pip may refuse to uninstall some .egg-info installs ("distutils installed project"). Reinstalling with pip over a conda package can also leave conda's own records out of step. Since setuptools is now excluded, this matters only for other libraries, which this test environment did not have.

Tests

  • New tests/test_entry_identity.py: a conda-style setuptools egg-info (plus wheel and pip) no longer makes the identity uncertain, and nothing is followed through it. This test fails without the fix. Also: an installer named in libraries is still identified; another egg-info library stays uncertain and the fix names it; the brick's own fix is the ADR's; the brick's own uncertainty comes before its libraries'.
  • tests/test_entry_record.py: one warning on an uncertain first write, none on a certain one, and none when the record is not written; a library-uncertain record is named both in the warning and in the reuse_or_refuse refusal.
  • python tools/check.py (ruff check, ruff format --check, pytest, code rules), Python 3.13, on the first commit: 9180 passed, 32 skipped. After the audit commit only the entry tests were rerun (test_entry_identity, test_entry_record, test_code_identity, test_entry_settings: 52 passed, 1 skipped), plus ruff.

https://claude.ai/code/session_01G3qp98tSnytZ9QCrHt6297


Generated by Claude Code

… write

Conda installs setuptools as an .egg-info without RECORD, and brick_identity's
closure (every extra included) reached it, so every entry record written in a
conda environment was uncertain and every rerun refused with
ENTRY_IDENTITY_UNCERTAIN (setuptools: RECORD missing).

- entry_identity: the installers pip, setuptools and wheel are neither listed
  nor followed in the requirement closure (INSTALL_TOOLS); every other library
  without RECORD stays uncertain (ADR 0007 (b)); a caller's explicit name is
  still identified. uncertain_library names the library behind an uncertain
  brick part.
- entry_record: write_entry_record warns (EntryIdentityWarning, text from
  identity_warning) that an output written under an uncertain identity will
  never be reused.
- entry_errors: uncertain_code_fix; the ENTRY_IDENTITY_UNCERTAIN fix names an
  uncertain library and why instead of telling the user to reinstall a brick
  that is already a released install.
- Tests with egg-info distributions in a temporary site folder; docs (contract
  21.2/21.4, plan 12 question 93), CHANGELOG Unreleased (v0.10.1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp98tSnytZ9QCrHt6297
…able fix

- write_entry_record warned before the exclusive open, so a record that was
  not written (one already there) still said the output was written; the
  warning now follows the write.
- The fix for an editable library said pip install "<name>==<version>",
  which pip skips as already satisfied; it now forces the reinstall
  (--force-reinstall --no-deps), as the RECORD-missing fix does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G3qp98tSnytZ9QCrHt6297
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.

2 participants