Skip to content

refactor: make tangle-api leaf via runtime model composition#10

Merged
Volv-G merged 2 commits into
masterfrom
piforge/tangle-cli-fix/leaf-tangle-api-runtime-model-co-fcb039f
Jul 3, 2026
Merged

refactor: make tangle-api leaf via runtime model composition#10
Volv-G merged 2 commits into
masterfrom
piforge/tangle-cli-fix/leaf-tangle-api-runtime-model-co-fcb039f

Conversation

@Volv-G

@Volv-G Volv-G commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Make tangle-api a leaf package while keeping public tangle-cli installs fully capable by default.

Key changes:

  • Add default tangle-cli -> tangle-api==0.0.1a3, so pip install tangle-cli includes checked-in static API bindings.
  • Keep tangle-cli[native] as a compatibility/no-op install alias for older instructions.
  • Remove the tangle-api -> tangle-cli dependency; tangle-api remains a leaf generated/static API package.
  • Regenerate tangle_api.generated.* from the checked-in OpenAPI snapshot as base generated models.
  • Move CLI model extension composition into tangle_cli.models.
  • Add an overridable generated-operations model lookup hook so TangleApiClient can use CLI-composed models while tangle-api remains independent.
  • Keep dynamic discovery/runtime and codegen in tangle-cli.

Design

tangle_api.generated.models now provides base generated API model classes only. It does not import tangle_cli and no longer bakes CLI-specific mixins into generated code.

tangle_cli.models composes the CLI public model namespace at import time using the existing MODEL_EXTENSIONS mapping. This preserves imports such as:

from tangle_cli.models import ComponentSpec

while keeping generated imports such as:

from tangle_api.generated.models import ComponentSpec

as the unextended base generated model.

Generated operation methods now resolve return model classes through an overridable hook. The default lookup uses base tangle_api.generated.models; TangleApiClient overrides it to use tangle_cli.models where CLI extension behavior is expected.

Packaging and custom API/codegen path

The default public install is now the fully capable path:

pip install tangle-cli

That install includes the matching official tangle-api package. The native extra remains available as a compatibility alias, but it does not add another dependency because tangle-api is already part of the default install.

Custom API/codegen users can still run codegen from the fully capable install; generation itself does not require removing official tangle-api.

Supported non-first-class custom paths:

  • For project-local generated APIs, generate into a local source tree such as src/tangle_api/generated and run from that project so local src/tangle_api shadows site-packages.
  • For packaged custom APIs, provide a distribution named tangle-api with a compatible version for this release, e.g. 0.0.1a3+yourorg for the tangle-api==0.0.1a3 dependency, via private index, --find-links, or uv source configuration.
  • As an expert escape hatch, --no-deps installs only tangle-cli and skips all dependencies; that environment must manually provide every required runtime dependency plus its generated/custom tangle_api package.

Codegen

Regenerated with:

uv run python -m tangle_cli.openapi.codegen --from-snapshot

This reads:

packages/tangle-api/src/tangle_api/schema/openapi.json

and writes:

packages/tangle-api/src/tangle_api/generated/__init__.py
packages/tangle-api/src/tangle_api/generated/runtime.py
packages/tangle-api/src/tangle_api/generated/models.py
packages/tangle-api/src/tangle_api/generated/operations.py

Assisted-By: devx/9c4ad24f-24d3-4eb9-8747-dbf53e3221df

@Volv-G Volv-G requested a review from Ark-kun as a code owner July 3, 2026 03:47

Volv-G commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Volv-G Volv-G changed the base branch from master to piforge/tangle-cli-fix/fix-packaging-aliases-and-native-7b1a94a July 3, 2026 03:47
@Volv-G Volv-G changed the base branch from piforge/tangle-cli-fix/fix-packaging-aliases-and-native-7b1a94a to master July 3, 2026 03:50
@Volv-G Volv-G changed the base branch from master to piforge/tangle-cli-fix/fix-packaging-aliases-and-native-7b1a94a July 3, 2026 03:51
Assisted-By: devx/9c4ad24f-24d3-4eb9-8747-dbf53e3221df
@Volv-G Volv-G changed the base branch from piforge/tangle-cli-fix/fix-packaging-aliases-and-native-7b1a94a to graphite-base/10 July 3, 2026 04:03
@Volv-G Volv-G force-pushed the piforge/tangle-cli-fix/leaf-tangle-api-runtime-model-co-fcb039f branch from ea72cd5 to 1ab260d Compare July 3, 2026 04:03
@Volv-G Volv-G changed the base branch from graphite-base/10 to master July 3, 2026 04:03
Assisted-By: devx/9c4ad24f-24d3-4eb9-8747-dbf53e3221df
@Volv-G Volv-G merged commit 3064235 into master Jul 3, 2026
3 checks passed
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