Documentation

Docs / Reference

ADR 0072 - Python workspace members installed as packages on the search path

Status: Accepted (delegated review, 2026-11-18)

Context

ADR 0015 fixed Graphvein's Python root policy (python-resolution.md): the repository root, directories of scanned pyproject.toml / setup.py / setup.cfg, their src child, implicit roots; ancestor roots as one search path, then sibling roots alone, then implicit roots. ADR 0069 made the search a PathFinder (row PS-M1 of docs/lang/python-structure.md) and listed in its known gaps that a workspace member installed as a package is not a root: on langflow, import lfx from src/backend/base/langflow/... finds the directory src/lfx (the member's project directory, a namespace portion on the ancestor root src) and stops, so about 23 sites get no edge, although the root pyproject.toml declares src/lfx as a uv workspace member whose regular package src/lfx/src/lfx is what an installed environment imports. The same shape exists wherever a project's directory and its package share a name (src layout under a sibling directory).

Options considered

  1. Keep the gap (counted as namespace_hides_concrete). Safe, loses the edges, and leaves a wrong fact: from lfx.tests import x claims src/lfx/tests/x.py through the namespace while the installed lfx has no tests subpackage.
  2. Treat every member's src as an ancestor root. Changes answers for every name in those directories and ignores what the build exposes.
  3. Read the declared environment: the workspace members (and editable path sources) a scanned pyproject.toml declares, the import packages each member's build backend exposes when that can be read exactly, and put exactly those packages on one search path entry after the ancestor roots, as site-packages comes after the script directory; let PathFinder's own rules decide (a namespace portion found earlier does not stop the search, a concrete package later wins). Chosen.
  4. Run the build backend (hatchling's editable build) at index time. Exact, but executes third-party code and needs a Python environment. Rejected; used once as a check (below).

Decision

Option 3, as row PS-M2 of docs/lang/python-structure.md (internal/lang/python/workspace.go, ModuleResolver.findWithSite):

Review fixes (S2XR)

The independent review the T020 task record (internal) (at 4fd8620, with CPython 3.14.10, hatchling 1.31.0, uv 0.13.9's source and the glob crate 0.3.4) found one class A finding and six class B. Decisions: model uv's exact rules where the langflow shape needs them, refuse what cannot be modelled exactly. Premises, from uv 0.13.9 crates/uv-workspace/src/workspace.rs (read from the PyPI sdist, MIT OR Apache-2.0) and glob 0.3.4 src/lib.rs:

Fixes, each with a unit test (TestWorkspaceMembers, TestWorkspaceEscapedRoot, TestWorkspaceScope, TestWorkspaceStdlibName, TestWorkspacePathSource, TestGlobMatch, tomlCases) and checked by mutation (each test fails with its fix removed; the C1 change is equivalent to the empty-match rule and needs no separate mutation):

Consequences

Known gaps

Review notes (acceptance, 2026-11-18)

Accepted after delegated review (2026-11-17). Steps: S2X implementation (row PS-M2), S2I (merge with the TypeScript and Rust structure stacks, extractors-43), one independent review (the T020 task record (internal): one class A, six class B, C items), S2XF fixes (A1 and B1-B6 fixed and mutation-checked, 11 of 11), a confirmation pass by the reviewer (every finding closed; one remaining lone-CR TOML form fixed afterwards).

Report a problem with this pageSource: docs/adr/0072-python-workspace-members.md