Skip to content

Remove backwards-compat shims guarding private symbols (#163) - #164

Merged
leynos merged 9 commits into
mainfrom
issue-163-sweep-codebase-for-unnecessary-backwards-compat-shims
Jul 22, 2026
Merged

Remove backwards-compat shims guarding private symbols (#163)#164
leynos merged 9 commits into
mainfrom
issue-163-sweep-codebase-for-unnecessary-backwards-compat-shims

Conversation

@lodyai

@lodyai lodyai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

This branch sweeps lading/ for backwards-compatibility shims, aliases, and wrappers guarding private (underscore-prefixed) symbols and removes those serving no genuine external-compatibility need. Private symbols carry no API stability contract, and lading's application code is the only consumer of its own internals, so the ad hoc compatibility layers kept solely so old test patches would keep resolving have been deleted, with the dependent tests retargeted at the canonical implementations.

Closes #163.

Inventory and disposition

Location Shim Disposition
lading/commands/publish.py Eleven bare aliases of publish_preflight privates (_preflight_argument_sets, _CargoPreflightOptions, _run_cargo_preflight, and friends) Removed; tests patch and call publish_preflight directly
lading/commands/publish.py _run_preflight_checks thin wrapper preserving the optional-configuration contract Removed; run() resolves configuration itself and calls publish_preflight._run_preflight_checks directly
lading/commands/publish.py Unused re-bindings _append_section, _format_plan, metadata_module, StripPatchesSetting, PublishPlanError Removed; plan-validation tests use publish_plan.PublishPlanError
lading/commands/bump.py Six re-exports of bump_toml helpers kept "to maintain backward compatibility", plus the redundant _log = LOGGER alias Removed; TOML helper tests exercise bump_toml directly
lading/commands/publish_plan.py Private definitions _append_section/_format_plan re-bound to the public names every consumer used Definitions renamed to the public names; aliases and stale __all__ entries dropped
lading/commands/publish_execution.py split_command wrapper (plus _split_command) over the runtime helper, with no production callers Removed along with its only test; cmd_mox_runner already uses lading.runtime.subprocess_runner.split_command
lading/commands/publish.py _invoke import Retained Genuine dependency-injection seam: run() uses it as the default CommandRunner, and tests stub it to intercept subprocess execution

No new port/adapter seam proved necessary: the churn that motivated the shims was a one-off module extraction (#96/#123), and the existing CommandRunner protocol in lading.runtime already provides the stable boundary for execution concerns.

Review walkthrough

Validation

  • make check-fmt: passed (137 files already formatted)
  • make lint: passed (ruff clean, interrogate 100%, pylint 10.00/10)
  • make typecheck: passed (ty check, all checks passed)
  • make test: passed (691 passed, 67 snapshots passed)
  • make markdownlint: passed (21 files, 0 errors)
  • make nixie: passed (all diagrams validated)
  • coderabbit review --agent: completed with 0 findings

References

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @LodyAI[bot], you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Remove private compatibility aliases and wrappers, route publish pre-flight calls and tests to canonical modules, export publish-plan helpers, standardize bump logging, migrate TOML helper usage, and update developer documentation.

Changes

Shim removal and canonical-target migration

Layer / File(s) Summary
Documentation and design updates
docs/developers-guide.md, docs/lading-design.md, typos.toml
Document private API stability, direct pre-flight integration, the updated publish execution flow, and spelling mappings.
Publish pre-flight direct invocation
lading/commands/publish.py
Remove the pre-flight wrapper and aliases, import publish_preflight directly, and preserve the direct PublishPlanError re-export.
Publish pre-flight test retargeting
tests/unit/conftest.py, tests/unit/publish/*
Patch and invoke pre-flight helpers, option types, and exceptions from publish_preflight.
Publish execution helper cleanup
lading/commands/publish_execution.py, tests/unit/publish/test_command_helpers.py
Remove split_command and test runtime subprocess and cmd-mox helpers directly.
Publish plan public helper renaming
lading/commands/publish_plan.py, tests/unit/publish/*, tests/unit/test_publish_*
Rename and export plan-formatting helpers, update references, and validate the canonical PublishPlanError type.
Bump logging and TOML helper migration
lading/commands/bump.py, tests/unit/test_bump_*.py
Use LOGGER directly, add bump TOML helper aliases, and migrate tests to bump_toml APIs.

Possibly related issues

  • leynos/lading#170: Both changes update compatibility boundaries and retarget related test seams.

Possibly related PRs

Suggested labels: Issue

Suggested reviewers: leynos, codescene-delta-analysis

Poem

Private shims fade from view,
Canonical calls now travel true.
Plans format with names made bright,
Pre-flight tests patch the source just right.
LOGGER hums through TOML’s tune.


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
Unit Architecture ❌ Error lading/commands/bump.py still re-exports private bump_toml helpers for compatibility, yet tests now call bump_toml directly and no legacy bump._... uses remain. Remove the leftover alias block from bump.py and keep callers/tests on lading.commands.bump_toml so the internal boundary stays explicit.
Linked Issues check ⚠️ Warning Issue #163 is not fully met because bump.py still adds backwards-compatibility re-exports for helper functions instead of removing them. Remove the new bump.py compatibility aliases and keep callers and tests on bump_toml directly.
Out of Scope Changes check ⚠️ Warning The PR includes unrelated typos.toml spelling-map edits that are not required by issue #163. Move the typos.toml updates into a separate change or justify them within the issue scope.
✅ Passed checks (17 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the shim-removal focus and includes the linked issue reference.
Description check ✅ Passed The description matches the shim-removal work and stays on-topic for the code changes.
Docstring Coverage ✅ Passed Docstring coverage is 86.96% which is sufficient. The required threshold is 80.00%.
Testing (Overall) ✅ Passed Tests assert filesystem writes, command arguments, error text, and public re-exports; no vacuous mock-only coverage found.
User-Facing Documentation ✅ Passed Pass: leave docs/users-guide.md untouched; the PR only removes internal shims and helper aliases, with no CLI behaviour change.
Developer Documentation ✅ Passed Verify docs/developers-guide.md and docs/lading-design.md were updated with the new internal-API boundaries; no execplan file is present.
Module-Level Documentation ✅ Passed All changed Python modules carry top-level docstrings; the publish, bump, plan, execution, and test modules all describe purpose and component relationships.
Testing (Unit And Behavioural) ✅ Passed PASS: The patch adds meaningful unit coverage for edge cases/error paths and preserves boundary coverage via publish.run/bump.run plus existing BDD/e2e CLI tests.
Testing (Property / Proof) ✅ Passed Treat this as a shim-removal refactor: it introduces no new range-wide invariant or proof assumption, so property tests or proofs are not warranted.
Testing (Compile-Time / Ui) ✅ Passed No Rust/TS compile-time surface exists in the touched code, and the human-readable publish summary is already guarded by focused snapshot tests in test_run_workspace_config.
Domain Architecture ✅ Passed Only docs and the command-layer publish_plan module changed; no domain model was touched, and publish_plan still translates workspace/config concepts at the application boundary.
Observability ✅ Passed No new operational path lacks logs/metrics; publish, preflight, subprocess, and lockfile flows already log failures, state, and redacted commands.
Security And Privacy ✅ Passed Only internal shims/docs/tests were retargeted; scans found no secrets, auth changes, unsafe deserialisation, or shell/eval injection in the touched code.
Performance And Resource Use ✅ Passed Only wrapper/alias removals and a linear section formatter changed; no new unbounded loops, repeated I/O, or material allocations appeared.
Concurrency And State ✅ Passed The PR only retargets shims/tests and docs; publish and preflight remain synchronous, and shared pipeline state stays in frozen dataclasses.
Architectural Complexity And Maintainability ✅ Passed PASS: the PR removes shims and thin wrappers, keeps only documented seams like _invoke, and introduces no new layers, registries, or orchestration machinery.
Rust Compiler Lint Integrity ✅ Passed No Rust files or Rust lint suppressions changed; the diff only touches docs and Python, so the check is not applicable.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-163-sweep-codebase-for-unnecessary-backwards-compat-shims

Comment @coderabbitai help to get the list of available commands.

codescene-access[bot]

This comment was marked as outdated.

@lodyai
lodyai Bot force-pushed the issue-163-sweep-codebase-for-unnecessary-backwards-compat-shims branch 2 times, most recently from 5122240 to 9bbce55 Compare July 8, 2026 20:44
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

lodyai Bot pushed a commit that referenced this pull request Jul 8, 2026
…actors

main independently landed this branch's bundled #95/#96/#97, refactored bump.py
(new `_CrateManifestOutcome` flow) and publish.py (#73/#96), and re-split the
bump tests into differently-named modules. This reconciles the #108 extraction
onto main's current tree as a single squashed change (the original 22 commits
are preserved on backup/issue-108-pre-rebase2-7df1480).

Landed cleanly (all now under the 400-line guideline):

- `lading/toml_coerce/` package (scalar/sequence/mapping coercers with
  structural pattern matching and numpy docstrings) + `config.py` (441->334)
  and `workspace/models.py` (576->194) consuming it via `functools.partial`.
- `lading/workspace/_coercion.py` + `graph_build.py` (builders out of
  `models`); `cli_options.py` (cyclopts args out of `cli.py`, 449->389);
  `bump_docs.py` condensed (402->393).
- `bump_manifests.py` re-derived against main's bump.py: the low-level manifest
  helpers, `_WORKSPACE_SELECTORS`, and `_BumpContext` move here; main's
  `_apply_crate_manifest_update`/`_CrateManifestOutcome` flow stays in `bump`
  and imports them. `bump.py` 552->427 (further trim is follow-up).

Test reconciliation: main's bump-test split is authoritative; this drops the
branch's parallel split modules and keeps main's plus the unique
`test_toml_coerce.py`. Per the no-compat-alias convention (#164),
`test_dependency_sections` now reads `_DEPENDENCY_SECTION_BY_KIND` from
`bump_manifests`.

Deferred: `publish.py` (741) extraction. main's #73/#96 refactored the
extracted pipeline functions and its tests patch `publish._*` seams; extracting
now requires rewriting many `monkeypatch.setattr` targets to `publish_pipeline`
(no-compat), which needs a focused full-context pass. publish.py is taken from
main unchanged; the orphaned `publish_pipeline.py` is removed.

Validated: check-fmt, lint (10.00/10), typecheck, test (717 passed, 70
snapshots), markdownlint, nixie — all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
leynos added a commit that referenced this pull request Jul 9, 2026
* Rebase issue-108 onto main; reconcile #108 extraction with main's refactors

main independently landed this branch's bundled #95/#96/#97, refactored bump.py
(new `_CrateManifestOutcome` flow) and publish.py (#73/#96), and re-split the
bump tests into differently-named modules. This reconciles the #108 extraction
onto main's current tree as a single squashed change (the original 22 commits
are preserved on backup/issue-108-pre-rebase2-7df1480).

Landed cleanly (all now under the 400-line guideline):

- `lading/toml_coerce/` package (scalar/sequence/mapping coercers with
  structural pattern matching and numpy docstrings) + `config.py` (441->334)
  and `workspace/models.py` (576->194) consuming it via `functools.partial`.
- `lading/workspace/_coercion.py` + `graph_build.py` (builders out of
  `models`); `cli_options.py` (cyclopts args out of `cli.py`, 449->389);
  `bump_docs.py` condensed (402->393).
- `bump_manifests.py` re-derived against main's bump.py: the low-level manifest
  helpers, `_WORKSPACE_SELECTORS`, and `_BumpContext` move here; main's
  `_apply_crate_manifest_update`/`_CrateManifestOutcome` flow stays in `bump`
  and imports them. `bump.py` 552->427 (further trim is follow-up).

Test reconciliation: main's bump-test split is authoritative; this drops the
branch's parallel split modules and keeps main's plus the unique
`test_toml_coerce.py`. Per the no-compat-alias convention (#164),
`test_dependency_sections` now reads `_DEPENDENCY_SECTION_BY_KIND` from
`bump_manifests`.

Deferred: `publish.py` (741) extraction. main's #73/#96 refactored the
extracted pipeline functions and its tests patch `publish._*` seams; extracting
now requires rewriting many `monkeypatch.setattr` targets to `publish_pipeline`
(no-compat), which needs a focused full-context pass. publish.py is taken from
main unchanged; the orphaned `publish_pipeline.py` is removed.

Validated: check-fmt, lint (10.00/10), typecheck, test (717 passed, 70
snapshots), markdownlint, nixie — all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Route coercion errors through _reject; fix stale docstring cross-refs

Centralise the canonical error-message shape in the toml_coerce helpers:
- `non_negative_int` type/parse-failure arms now raise
  `_reject(value, field_name, "an integer", error)` (identical message, so the
  snapshot is unchanged); the `str` arm preserves `from exc` chaining. The
  negative-value message stays a plain value error (the `"; received {type}."`
  type-shape does not fit it).
- `expect_sequence`'s None-disallowed branch and both `string_matrix` failure
  arms now route through `_reject`, so they carry the canonical
  `"; received {type}."` suffix. Regenerated the `preflight.aux_build` line of
  the `test_coercion_error_messages_are_stable` snapshot accordingly.

Docstrings: `_BumpContext` now points at `bump._apply_crate_manifest_update`
(the current consumer; `_update_crate_manifest` was removed), and
`graph_build`'s module docstring points coercion bindings at
`lading.workspace._coercion` rather than `models`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Lock down canonical coercion-message contracts in tests

Address the "canonical-message branches unguarded" review finding by asserting
exact error wording (not just the raised type) on the branches that recently
moved to `_reject`, and by covering the `expect_mapping` success path:

- `test_expect_sequence_handles_none` now asserts the disallowed-None message
  `"f must be a sequence; received NoneType."`.
- `test_string_matrix_rejects_non_sequence_values` asserts the top-level
  `"... must be a sequence of string sequences; received <type>."` shape.
- `test_string_matrix_rejects_non_string_rows` asserts the row-level
  `"demo.matrix[1] must be a sequence of strings; received <type>."` shape.
- `test_mapping_helpers_reject_non_mappings` becomes
  `test_mapping_helpers_accept_and_reject_mappings`, adding a passthrough
  assertion that a valid mapping is returned unchanged.

Tests are strengthened in place (no new methods) to stay within the
`TestTomlCoerce` PLR0904 public-method cap. The graph_build module-docstring
finding was already fixed in the prior commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Dedup coercion rejection-assert tail via a shared helper

Resolve the CodeScene "Code Duplication" finding across the four rejection
tests. Extract the common raise/capture/assert-substring/assert-type-name tail
into a generic `_assert_rejection(call, expected_prefix, bad_value, error)`
helper. `_assert_rejects_indexed_non_string` now builds the indexed input and
delegates to it, and the two `string_matrix` rejection tests call it directly
instead of repeating the tail inline. The `string_tuple` and
`validate_string_sequence` rejection tests are unchanged — they already route
through `_assert_rejects_indexed_non_string`.

All four tests stay distinct, independently discoverable methods; assertion
semantics and field-name literals are unchanged. (The helper's summary
docstring is wrapped to keep it within the line-length limit.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: leynos <leynos@rohga>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@leynos
leynos marked this pull request as ready for review July 9, 2026 12:58

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

chatgpt-codex-connector[bot]

This comment was marked as resolved.

codescene-access[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot added the Issue label Jul 14, 2026
coderabbitai[bot]

This comment was marked as resolved.

@lodyai
lodyai Bot force-pushed the issue-163-sweep-codebase-for-unnecessary-backwards-compat-shims branch from 525dff0 to e178994 Compare July 14, 2026 18:18
@pandalump

Copy link
Copy Markdown
Collaborator

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

codescene-access[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as resolved.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Jul 21, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following now been resolved?

lading/commands/bump.py (1)

44-44: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Remove the private TOML compatibility aliases.
The cleanup at Line 44 is undermined by the aliases added at Lines 542-543. Remove that compatibility block; it recreates the undocumented private API that Issue #163 explicitly requires this PR to eliminate. Keep callers and tests on the canonical lading.commands.bump_toml helpers.
Also applies to: 542-543

🤖 Detailed instructions

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @lading/commands/bump.py at line 44, Remove the private TOML compatibility
alias block near the module’s TOML helper definitions, including the aliases
around lines 542-543. Update any remaining callers or tests to use the canonical
lading.commands.bump_toml helpers, leaving the existing cleanup intact.

lading/commands/publish_plan.py (1)

215-225: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Document the public helpers and add the explicit return.
Add NumPy-style Parameters and Returns sections to append_section and format_plan, then finish append_section with a bare return instead of relying on implicit None.

def append_section[T](...):
     ...
         lines.extend(f"- {formatter(item)}" for item in items)
+    return

As per coding guidelines and path instructions, public interfaces require NumPy-format docstrings and explicit returns.
Also applies to: 228-229

🤖 Detailed instructions

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @lading/commands/publish_plan.py around lines 215 - 225, Add NumPy-style
Parameters and Returns sections to the public helpers append_section and
format_plan, documenting their arguments and None return values. In
append_section, add an explicit bare return after the conditional
section-appending logic while preserving its existing behavior.

Sources: Coding guidelines, Path instructions

@leynos

leynos commented Jul 21, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following now been resolved?

lading/commands/bump.py (1)

542-543: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Remove the private compatibility re-exports.
Delete the bottom-of-file aliases at Lines 542-543. The migrated tests already call bump_toml.*, so retaining underscore-prefixed names on bump recreates the private API shims that this PR and Issue #163 explicitly require removing.

🤖 Detailed instructions

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @lading/commands/bump.py around lines 542 - 543, Remove the bottom-of-file
private compatibility aliases following the return in the relevant bump module,
leaving only the sections return and no underscore-prefixed re-exports on bump.
Preserve the migrated bump_toml API usage and avoid adding replacement shims.

lading/commands/publish_plan.py (1)

215-223: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Document the newly exported helpers as public interfaces.
Add NumPy-style Parameters and Returns sections to append_section and format_plan. Removing the private marker and adding both names to __all__ makes the current one-line summaries insufficient.
Also applies to: 228-229, 262-267

🤖 Detailed instructions

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @lading/commands/publish_plan.py around lines 215 - 223, The exported helpers
append_section and format_plan need complete public API documentation. Remove
their private markers, add both function names to all, and expand each
docstring with NumPy-style Parameters and Returns sections describing their
arguments and return behavior while preserving the existing summaries.

Sources: Coding guidelines, Path instructions

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

@leynos

leynos commented Jul 21, 2026

Copy link
Copy Markdown
Owner

@coderabbitai the rules prohibit implicit return only if the function may return a value.

R501 — Avoid Explicit return None if It's the Only Return

# BAD:
def func():
    return None

# GOOD:
def func():
    return

Use return alone instead of return None when the function's only result is None.


R502 — Avoid Implicit None in Functions That May Return a Value

# BAD:
def func(x):
    if x > 0:
        return x
    # implicitly returns None (bad)

# GOOD:
def func(x):
    if x > 0:
        return x
    return 0

Ensure all branches explicitly return a value if any branch does.


R503 — Add an Explicit Return at the End

# BAD:
def func(x):
    if x > 0:
        return x
    # no return (bad)

# GOOD:
def func(x):
    if x > 0:
        return x
    return -1

Don't rely on implicit None—always return something at the end.

This is unclear. Please raise GitHub issues against leynos/agent-template-python and leynos/lading recommending:

Don't rely on implicit None if the function may return a value elsewhere—always return something at the end.

@leynos

leynos commented Jul 21, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

codescene-access[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/developers-guide.md`:
- Around line 544-554: Add a concise caption immediately before the shim
inventory table in the developers guide, using wording such as “Shim inventory.”
Preserve the table content and formatting unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: edff1c1d-662e-49a2-abdf-8534b66194cc

📥 Commits

Reviewing files that changed from the base of the PR and between e178994 and 66f99ac.

📒 Files selected for processing (4)
  • docs/developers-guide.md
  • lading/commands/publish_plan.py
  • tests/unit/test_publish_planning.py
  • typos.toml
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/cmd-mox (auto-detected)
  • leynos/cuprum (auto-detected)
  • leynos/shared-actions (auto-detected)

Comment thread docs/developers-guide.md
codescene-access[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lading/commands/publish_plan.py`:
- Around line 274-284: Update the PublishPlan doctest in format_plan to
construct workspace_root with Path("ws") instead of an absolute Path("/ws"), and
change the expected “Publish plan for” output to “ws” so the example is
platform-neutral.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7981516c-30cc-4d20-bdfd-2c7b1bbfb30d

📥 Commits

Reviewing files that changed from the base of the PR and between 66f99ac and 1c320e2.

📒 Files selected for processing (1)
  • lading/commands/publish_plan.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/cmd-mox (auto-detected)
  • leynos/cuprum (auto-detected)
  • leynos/shared-actions (auto-detected)

Comment thread lading/commands/publish_plan.py
leynos added 9 commits July 22, 2026 01:09
`publish_plan` defined `_append_section` and `_format_plan` privately
and then re-bound them to public aliases; every consumer used the
public names. Rename the definitions to `append_section` and
`format_plan`, drop the aliases, and remove the underscore variants
(plus the internal `_format_crates_section`) from `__all__`.

`publish_execution` carried a `split_command` wrapper over
`lading.runtime.subprocess_runner.split_command` whose only purpose was
mapping `ValueError` to `PublishPreflightError`. Nothing in production
code called it — `cmd_mox_runner` uses the runtime helper directly —
so remove the wrapper, its alias, and its only test.

Refresh the publish-flow diagram in `docs/lading-design.md`, which
still showed `split_command` and the cmd-mox helpers under
`publish_execution`; those moved to `lading.testing.cmd_mox_runner`
in #76.
Delete the backwards-compatibility layer that `publish.py` kept for
test patches after the pre-flight helpers moved to
`publish_preflight` (#96, #123):

- Drop the eleven bare aliases (`_preflight_argument_sets`,
  `_CargoPreflightOptions`, `_run_cargo_preflight`, and friends).
- Drop the thin `_run_preflight_checks` wrapper that resolved an
  optional `configuration`; `run()` already resolves configuration
  before the call, so it now invokes
  `publish_preflight._run_preflight_checks` directly.
- Drop the unused `_append_section`, `_format_plan`,
  `metadata_module`, `StripPatchesSetting`, and `PublishPlanError`
  re-bindings.

Private symbols carry no stability contract and lading is the only
consumer of its own internals, so tests now patch and call the
canonical module: conftest fixtures stub
`publish_preflight._run_preflight_checks`, the preflight suites
target `publish_preflight` directly, and the plan-validation tests
raise `publish_plan.PublishPlanError`. The two tests that pinned the
wrapper's aliasing behaviour are removed with the wrapper.
Drop the six module-level re-exports (`_parse_manifest`,
`_select_table`, `_assign_version`, `_value_matches`,
`_update_dependency_sections`, `_update_dependency_table`) that
`bump.py` kept solely so existing tests could keep patching the old
names. The TOML helper tests now exercise `bump_toml` directly.

Also fold the redundant `_log = LOGGER` alias into a single `LOGGER`
name; the README-transposition failure path now logs via
`LOGGER.exception`, matching the logging convention enforced by lint
for handlers that re-raise.
Record in the developers' guide that private symbols carry no
stability contract: when a helper moves to a new canonical module,
update call sites and test patch targets in the same change instead of
leaving aliases or thin wrappers behind. Point recurring churn at an
explicit port (as with `CommandRunner`) rather than ad hoc shims.

Rewrite the pre-flight validation section, which still described the
`publish.py` re-exports and optional-configuration wrapper removed in
this branch.
The shim sweep removed `PublishPlanError` from `publish.py` alongside the
private compatibility aliases. That exception is public API, however: the
still-exported `publish.plan_publication()` raises it, so callers catching
`except publish.PublishPlanError` began failing with `AttributeError`.

Re-export it explicitly with `PublishPlanError as PublishPlanError` so the
public entry point and the exception it raises stay catchable from the same
module. The no-alias convention in the developers' guide is clarified to
scope it to private, underscore-prefixed symbols, and a regression test
asserts `publish.PublishPlanError` remains the canonical class and catches
planning failures.
Address review feedback on the compatibility-shim sweep.

Expand the "Internal APIs carry no compatibility aliases" section of the
developers' guide with a repository-wide inventory mapping every removed
private alias, wrapper, and re-export to its canonical replacement, plus a
"Retained boundaries" subsection recording why `publish._invoke`, the public
`publish.PublishPlanError` re-export, and the `CommandRunner` port are kept.
This gives issue #163 an explicit audit trail.

Give the now-public `append_section` and `format_plan` helpers full
NumPy-style `Parameters`/`Returns` docstrings, and tighten
`test_publish_reexports_plan_error_for_public_callers` with a diagnostic
assertion message and a `match="dependency cycle"` constraint on the raised
`PublishPlanError`.
The markdownlint gate runs `scripts/typos_rollout.py`, which regenerates
`typos.toml` from its upstream authority. The tracked file had drifted behind
the authority, so the gate refreshed it, adding the `polymerize` word family.
Commit the deterministic regeneration to keep the working tree clean; the
content is generated, not hand-authored, and unrelated to the shim sweep.
Address review feedback asking the public `append_section` and `format_plan`
helpers to demonstrate representative usage. Add NumPy-style `Examples`
sections with executable `>>>` doctests, matching the house style used by
helpers such as `command_detail`. The `append_section` example shows both the
append and the empty-items no-op; the `format_plan` example renders an empty
plan. Both doctests pass under `python -m doctest`. Existing `Parameters` and
`Returns` sections are unchanged.
Address two review nits on the compatibility-shim documentation.

Add a `#### Shim inventory` subheading before the inventory table in the
developers' guide so the table is captioned, consistent with the sibling
`#### Retained boundaries` heading. A heading is used rather than bold text
because markdownlint MD036 (emphasis-as-heading) is active.

Construct the `format_plan` doctest with a relative `Path("ws")` instead of
an absolute `Path("/ws")` so the rendered "Publish plan for ws" line is
platform-neutral (an absolute path renders differently on Windows). The
doctest still passes.
@lodyai
lodyai Bot force-pushed the issue-163-sweep-codebase-for-unnecessary-backwards-compat-shims branch from 1c320e2 to e314b60 Compare July 21, 2026 23:13

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our agent can fix these. Install it.

Gates Passed
6 Quality Gates Passed

Absence of Expected Change Pattern

  • lading/lading/commands/bump.py is usually changed with: lading/tests/unit/test_cli.py
  • lading/lading/commands/publish.py is usually changed with: lading/tests/bdd/steps/test_publish_steps.py

Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No quality gates enabled for this code.

@pandalump

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot]

This comment was marked as resolved.

@leynos

leynos commented Jul 22, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following now been resolved?

lading/commands/bump.py (1)

44-44: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Delete the reintroduced private aliases before removing this import.
Line 44 removes bump_toml, but Lines 542-543 still dereference it to create compatibility aliases. Importing lading.commands.bump therefore raises NameError. Delete the bottom compatibility block; the migrated tests already use canonical bump_toml helpers.
Based on the PR objective to remove private compatibility shims, retain no test-only aliases in lading/commands/bump.py.
Also applies to: 542-543

🤖 Detailed instructions

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @lading/commands/bump.py at line 44, Remove the compatibility alias block
near the bottom of the module that dereferences the removed private import,
including the aliases around bump_toml. Ensure importing the module no longer
references undefined symbols and retain only the canonical helpers without
test-only aliases.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '== bump.py import and compatibility-alias regions =='
sed -n '30,58p' lading/commands/bump.py
tail -n 80 lading/commands/bump.py

printf '%s\n' '== Any former private TOML alias assignments in bump.py =='
rg -n -C 3 \
  '^\s*_(parse_manifest|select_table|assign_version|value_matches|update_dependency_sections|update_dependency_table)\s*=' \
  lading/commands/bump.py || true

printf '%s\n' '== Current bump_toml import/references in bump.py =='
rg -n -C 2 '\bbump_toml\b' lading/commands/bump.py || true

printf '%s\n' '== Production/test callers of the former bump private helpers =='
rg -n -C 2 \
  '\bbump\._(parse_manifest|select_table|assign_version|value_matches|update_dependency_sections|update_dependency_table)\b|from\s+lading\.commands\.bump\s+import\s+.*_(parse_manifest|select_table|assign_version|value_matches|update_dependency_sections|update_dependency_table)\b' \
  lading tests || true

printf '%s\n' '== PR-head diff for bump-related files =='
git status --short
git diff -- lading/commands/bump.py lading/commands/bump_toml.py tests/unit/test_bump_toml_helpers.py tests/unit/test_bump_manifest_writing.py
git diff --cached -- lading/commands/bump.py lading/commands/bump_toml.py tests/unit/test_bump_toml_helpers.py tests/unit/test_bump_manifest_writing.py

Length of output: 5078


@leynos Mark this finding resolved.

lading/commands/bump.py contains neither a bump_toml import/reference nor the former underscore-prefixed TOML compatibility aliases. No production or test caller targets bump._parse_manifest, bump._select_table, bump._assign_version, bump._value_matches, bump._update_dependency_sections, or bump._update_dependency_table.

The reported import-time NameError cannot occur, and the PR retains no test-only private TOML shim.

@leynos
leynos merged commit d950bc1 into main Jul 22, 2026
7 checks passed
@leynos
leynos deleted the issue-163-sweep-codebase-for-unnecessary-backwards-compat-shims branch July 22, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sweep codebase for unnecessary backwards-compatibility shims on private APIs

2 participants