Skip to content

Add reference lookup and pure entry rename, and split refs into references and sensitive - #49

Open
nicoloesch wants to merge 8 commits into
mainfrom
24-reverse-reference-lookup
Open

nicoloesch wants to merge 8 commits into
mainfrom
24-reverse-reference-lookup

Conversation

@nicoloesch

@nicoloesch nicoloesch commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds reverse reference lookup (which entries and package fields name a given entry) and a pure, atomic rename_entry that repoints every reference. Both read the existing RefTo markers, so forward and reverse lookups share one walk.

Along the way, the reference logic is gathered in references.py, entry classes now carry their own section name, and refs.py is split into references.py and sensitive.py to remove the refs/references ambiguity. refs.py stays as a deprecated alias.

Changes

  • Add reference lookup in references.py
    • collect_references lists every reference in the stack. references_to filters it by target.
    • find_references does the same but discovers installed package classes from the omop.config entry points and reports broken, duplicate or invalid registrations as DiscoveryProblem.
    • [tools.*] fields are read through the package classes. A tool section with no known class is listed in unknown_tool_schemas, never treated as having no references. An omitted field counts through its default, and so does every field of an installed package whose section is absent from the config.
    • Results are Reference, ReferenceReport and DiscoveryProblem, exported from the package.
  • Add rename_entry
    • Returns a validated copy and leaves the input unchanged. No file I/O.
    • Keeps the entry's position, repoints core and [tools.*] references, and writes an explicit new value where a package field referred to the old name through its default. A package with no section gets one holding just that value.
    • Refuses a missing entry, an invalid, unchanged or taken name, and any tool section with an unknown package class.
    • Validates the whole stack and the repointed package sections. It raises instead of returning a partial result.
  • Store the section on the entry class
    • Sectioned carries section, and Referenceable marks the classes a RefTo may name. The abstract DatabaseConfig is sectioned but not referenceable.
    • Replaces the _REF_SECTIONS table. RefTo.target is typed as type[Referenceable].
    • StackConfig.entry_sections() is derived from the field annotations, with tests that each class's section matches its field.
    • The CLI helpers _add_entry and _list_entries read the section from the class instead of taking a string.
  • Move the forward helpers unresolved_refs, mismatched_kind_refs and UnknownRefTarget from stack_config.py to references.py. They share a walker with the new lookup and remain importable from stack_config.
  • Split refs.py
    • RefTo, Referenceable and _iter_refs move to references.py.
    • Sensitive, Secret, masking and error sanitising move to sensitive.py. Secret and Sensitive are now exported from the package root.
    • refs.py remains as an alias that warns with DeprecationWarning and is to be removed in the next major release.
  • Add package_entry_points() as the single reader of the omop.config group, used by the CLI and discovery.
  • Update docs/api for the new locations and add the lookup and rename. Add tests for lookup, discovery, rename, section consistency and the refs alias.

Behaviour

  • Non-breaking. oa_configurator.refs.* and the stack_config helper paths still resolve. Only refs emits a deprecation warning.
  • CLI output is unchanged, checked by running the same commands before and after and diffing the output.
  • Passing an abstract class such as DatabaseConfig to RefTo is now also a type error. At runtime it still raises UnknownRefTarget as before.

Checklist

  • Applied exactly one label (feature)
  • Tests pass locally (pytest -q): 674 passed
  • Lint and type checks pass (ruff check ., ty check src/ tests/)

@nicoloesch nicoloesch added the feature New backwards-compatible functionality. MINOR: x.y+1.z label Oct 25, 2026
@nicoloesch
nicoloesch marked this pull request as ready for review November 7, 2026 17:38
@nicoloesch
nicoloesch requested a review from gkennos November 8, 2026 14:43
Base automatically changed from 38-bump-ty-ruff to main November 16, 2026 04:43
@nicoloesch
nicoloesch force-pushed the 24-reverse-reference-lookup branch from 2d86015 to 1d65ff8 Compare November 16, 2026 21:36
@nicoloesch
nicoloesch added this pull request to stack #60 November 16, 2026 22:05
Comment thread src/oa_configurator/references.py Resolved
@nicoloesch nicoloesch added feature New backwards-compatible functionality. MINOR: x.y+1.z and removed feature New backwards-compatible functionality. MINOR: x.y+1.z labels Nov 17, 2026
@nicoloesch
nicoloesch requested a review from gkennos November 17, 2026 02:26

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

feature New backwards-compatible functionality. MINOR: x.y+1.z

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pure, atomic named-entry rename with reference repointing Add reverse-reference lookup with explicit unknown-package reporting

2 participants