Skip to content

Tidy minor structural overlaps (#107) - #120

Open
leynos wants to merge 7 commits into
mainfrom
issue-107-minor-structural-overlaps
Open

Tidy minor structural overlaps (#107)#120
leynos wants to merge 7 commits into
mainfrom
issue-107-minor-structural-overlaps

Conversation

@leynos

@leynos leynos commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #107

  • 13a_format_crates_section folded into the single section renderer. The renderer is now _render_section, a query returning the section lines (also keeps the signature within the four-argument lint ceiling), with an optional empty_message; _format_plan composes it for every section.
  • 13b — the live pipeline catches PublishPreflightError alone, with a comment noting that PublishError subclasses it so the redundant tuple is not reintroduced by accident.
  • 13ccli._run_with_context resolves the configuration scope first (a nullcontext when already loaded) and runs a single load-workspace-and-run block.
  • 13dutils.commands.LADING_CATALOGUE is documented as staged-but-not-wired in both the module docstring and the developers' guide, pointing at the roadmap Phase 5 wiring steps.

Testing

  • Hypothesis property test pins the render_section header/item/empty-message invariants.
  • syrupy snapshots lock the fully rendered publish plan with and without publishable crates.
  • Behavioural test pins identical downstream behaviour for both _run_with_context branches.
  • make check-fmt, make lint, make typecheck, and make test (560 passed) all green.
  • coderabbit review --agent: 0 findings.

🤖 Generated with Claude Code

Summary by Sourcery

Refine publish plan rendering and CLI execution context handling while clarifying command catalogue documentation and strengthening tests around these behaviours.

Enhancements:

  • Unify publish plan section rendering behind a single render_section helper that returns fully rendered section lines, including optional empty-state messages, and wire it through format_plan.
  • Simplify _run_with_context to share a single load-workspace-and-run path regardless of whether configuration was preloaded or freshly loaded, avoiding duplicated logic.
  • Streamline live publication pipeline error handling to rely on PublishPreflightError alone, with documentation of PublishError subclassing for future maintainability.

Documentation:

  • Document LADING_CATALOGUE as a staged but not yet wired programme catalogue in the developers guide, including its intended future role in the runner migration roadmap.

Tests:

  • Update publish plan formatting tests to target render_section, add property-based invariants for section rendering, and introduce snapshot tests for full publish plan output with and without publishable crates.
  • Add a behavioural test to ensure _run_with_context behaves identically when configuration is preloaded versus freshly loaded.

References

@coderabbitai

coderabbitai Bot commented Jun 10, 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b97f6b8e-2f2d-4681-a0af-444952b75b4f

📥 Commits

Reviewing files that changed from the base of the PR and between bf456eb and ede85f9.

📒 Files selected for processing (3)
  • docs/developers-guide.md
  • lading/utils/commands.py
  • tests/unit/test_publish_formatting.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)

Summary

  • Consolidated publish-plan section rendering with the new render_section helper, optional empty messages, snapshots, and Hypothesis property tests; retained append_section as a compatibility wrapper.
  • Simplified live publication error handling by catching PublishPreflightError.
  • Unified CLI configuration loading and execution paths, with behavioural coverage for disk-loaded and preloaded configurations.
  • Documented publish-plan output for users and clarified that LADING_CATALOGUE remains a staged artefact pending roadmap Phase 5.2.
  • Removed duplicated formatting and skipped-section tests while retaining unique coverage.

Testing

  • Added renderer invariants, formatting snapshots, and public cli.app boundary tests.

Walkthrough

Changes

Publish formatting

Layer / File(s) Summary
Unify publish-plan rendering
lading/commands/publish_plan.py, tests/unit/publish/*, tests/unit/publish/__snapshots__/*, docs/users-guide.md, docs/developers-guide.md, tests/unit/test_publish_formatting.py
Add and export render_section, delegate append_section to it, assemble plan output through it, and cover empty, formatted, property-based, snapshot, and documented output cases.

Execution context

Layer / File(s) Summary
Consolidate execution context
lading/cli.py, lading/commands/publish.py, tests/unit/test_cli.py
Use one configuration and command-runner context path, verify equivalent loaded-configuration branches, and catch PublishPreflightError for the live pipeline.

Catalogue migration

Layer / File(s) Summary
Document staged catalogue migration
lading/utils/commands.py, docs/developers-guide.md
Document that LADING_CATALOGUE is staged and that subprocess execution remains directly spawned until the Phase 5 runner migration.

Possibly related PRs

Suggested labels: Issue

Poem

Align the sections, let bullets fly,
Give empty plans a clear reply.
Unify contexts, catch errors clean,
Keep staged commands off the scene.
Test the flow and ship it keen!


Caution

Pre-merge checks failed

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

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Module-Level Documentation ❌ Error lading/commands/publish_plan.py only says 'Publication planning and formatting helpers.'; it does not clearly explain purpose or its relation to publish.py/the CLI. Expand the publish_plan.py module docstring to state its role in planning and formatting publish output and how publish.py, cli.py, and the snapshot tests depend on it.
✅ Passed checks (19 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the PR’s structural tidy-up scope and includes the linked issue reference (#107).
Description check ✅ Passed The description clearly covers the same section-rendering, CLI, error-handling, and documentation changes.
Linked Issues check ✅ Passed The changes satisfy #107’s four items: section renderer, exception tuple, _run_with_context, and catalogue note.
Out of Scope Changes check ✅ Passed No clear out-of-scope code changes appear; the docs, tests, and refactors all support the linked objectives.
Docstring Coverage ✅ Passed Docstring coverage is 88.24% which is sufficient. The required threshold is 80.00%.
Testing (Overall) ✅ Passed Accept the new tests: property checks, snapshot oracles, and branch-equivalence assertions fail on plausible regressions.
User-Facing Documentation ✅ Passed PASS: docs/users-guide.md documents the new publish-plan summary and existing user-facing publish behaviour, covering the PR’s visible changes.
Developer Documentation ✅ Passed PASS: docs/developers-guide.md covers the new APIs/boundaries; roadmap 5.1 is checked off, 5.2 stays open, and there are no locale sync issues.
Testing (Unit And Behavioural) ✅ Passed Unit tests cover render_section invariants, empty-state snapshots, and append_section delegation; the behavioural test hits the public cli.app boundary across both config branches.
Testing (Property / Proof) ✅ Passed PASS: render_section’s header/item/empty-message invariant is covered by Hypothesis, and snapshots pin full-plan output; no proof obligation is introduced.
Testing (Compile-Time / Ui) ✅ Passed PASS: no Rust/TypeScript compile-time surface exists here, and publish-plan output is locked by focused snapshots plus Hypothesis invariants with workspace-path redaction.
Unit Architecture ✅ Passed Section rendering is now a pure query, mutation stays explicit in append_section, and _run_with_context keeps the load/run seam injectable with both config branches tested.
Domain Architecture ✅ Passed Changes stay in CLI, command, docs, and tests; no domain model now depends on transport or infrastructure details.
Observability ✅ Passed Existing logs cover workflow start, mode selection, crate boundaries and aborts; no new operational boundary or telemetry gap was introduced by this refactor.
Security And Privacy ✅ Passed Approve: keep the snapshots path-normalised; no secrets, permission widening, or trust-boundary regressions appear.
Performance And Resource Use ✅ Passed PASS: The new work is linear section formatting on CLI output and a single load/run path; no new hot-path loops, retries, or repeated I/O appear.
Concurrency And State ✅ Passed No new shared mutable state, locks, async tasks, or parallelism were introduced; _run_with_context just selects a context and tests pin both config branches.
Architectural Complexity And Maintainability ✅ Passed PASS: render_section is a thin pure helper replacing duplicated formatting; _run_with_context is a single with-block; LADING_CATALOGUE is explicitly staged, not wired.
Rust Compiler Lint Integrity ✅ Passed The PR changes only Python/docs; no Rust files, lint suppressions, or suspicious Rust clones appear in the diff.
📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #107

✨ 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-107-minor-structural-overlaps

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

@sourcery-ai

sourcery-ai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors publish-plan section rendering into a single reusable render_section helper that returns lines, updates format_plan to use it, tightens CLI configuration scoping in _run_with_context, simplifies live publication error handling, and documents the staged LADING_CATALOGUE plus adds property/snapshot tests to pin behaviours.

Sequence diagram for unified _run_with_context execution flow

sequenceDiagram
    actor User
    participant CLI as cli._run_with_context
    participant Config as config
    participant Meta as metadata_module
    participant Workspace as load_workspace
    participant Runner as runner

    User->>CLI: _run_with_context(workspace_root, runner, command_runner)
    CLI->>Config: current_configuration()
    alt configuration not loaded
        Config-->>CLI: raise ConfigurationNotLoadedError
        CLI->>Config: load_configuration(workspace_root)
        Config-->>CLI: configuration
        CLI->>Config: use_configuration(configuration)
        Config-->>CLI: configuration_scope
    else configuration already loaded
        Config-->>CLI: configuration
        Note over CLI: configuration_scope = nullcontext()
    end

    CLI->>Meta: use_command_runner(active_runner)
    activate Meta
    CLI->>Workspace: load_workspace(workspace_root)
    Workspace-->>CLI: workspace_model
    CLI->>Runner: runner(workspace_root, configuration, workspace_model, active_runner)
    Runner-->>CLI: result
    Meta-->>CLI: exit
    CLI-->>User: result
Loading

File-Level Changes

Change Details Files
Unify publish-plan section rendering into a single pure helper that returns rendered lines and wire it through the plan formatter.
  • Replace _append_section and _format_crates_section with a single generic _render_section that formats items with an optional empty_message and returns a list of lines instead of mutating an accumulator.
  • Update _format_plan to use _render_section for all sections, extending the accumulated lines with its result and formatting crates via lambdas.
  • Rename the public helper from append_section to render_section and update all exports accordingly.
lading/commands/publish_plan.py
Update tests around publish-plan formatting to target render_section and add stronger property and snapshot coverage.
  • Rename append_section tests to render_section variants and adapt them to the new return-value API instead of in-place mutation.
  • Add a test for rendering an empty_message when a section is empty and a Hypothesis property test that pins the header/item/empty-message invariants for render_section.
  • Introduce a helper to normalise workspace paths in messages and add syrupy snapshot tests for full publish-plan output with and without publishable crates.
tests/unit/publish/test_formatting_helpers.py
tests/unit/test_publish_formatting.py
tests/unit/publish/__snapshots__/test_formatting_helpers.ambr
Deduplicate configuration handling in _run_with_context so both branches share a single load-workspace-and-run block.
  • Introduce a configuration_scope using contextlib.nullcontext by default, switching to config.use_configuration(configuration) only when configuration must be freshly loaded.
  • Rework _run_with_context to always execute a single with-block that installs the configuration scope and command runner, then loads the workspace and invokes the runner.
  • Add a behavioural test that exercises both pre-loaded and freshly loaded configuration paths and asserts identical downstream behaviour and arguments.
lading/cli.py
tests/unit/test_cli.py
Simplify live publication error handling and log behaviour.
  • Change the live publication pipeline to catch only PublishPreflightError, relying on the fact that PublishError subclasses PublishPreflightError.
  • Add an explanatory comment to prevent reintroduction of redundant exception tuples in the future.
lading/commands/publish.py
Clarify documentation around the staged LADING_CATALOGUE command registry.
  • Update the developers guide to describe LADING_CATALOGUE as a staged but not yet wired programme catalogue and explain its intended Phase 5 usage as a registration point rather than active allowlist enforcement.
docs/developers-guide.md
lading/utils/commands.py

Assessment against linked issues

Issue Objective Addressed Explanation
#107 Refactor publish plan section rendering into a single reusable renderer with optional empty_message, update all call sites, and add tests (property-based and snapshot) that cover header/item/empty-message behaviour and full plan output.
#107 Simplify error handling in the live publication pipeline to rely on the base PublishPreflightError (with documentation of the subclass relationship) and refactor cli._run_with_context to a single load-and-run block, with a behavioural test confirming both configuration branches behave identically.
#107 Document LADING_CATALOGUE as a staged-but-not-yet-wired migration artifact in the developers guide and in the commands module, clarifying that it will become live in the Phase 5 runner migration.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codescene-delta-analysis codescene-delta-analysis 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/publish.py is usually changed with: lading/tests/bdd/steps/test_publish_steps.py
  • lading/tests/unit/test_cli.py is usually changed with: lading/lading/commands/bump.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.

@lodyai
lodyai Bot force-pushed the issue-107-minor-structural-overlaps branch from c47f324 to f63b22c Compare July 8, 2026 18:11
codescene-access[bot]

This comment was marked as outdated.

@leynos
leynos marked this pull request as ready for review July 8, 2026 20:30

@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.

@lodyai
lodyai Bot force-pushed the issue-107-minor-structural-overlaps branch from f63b22c to 1f4ce2a Compare July 8, 2026 20:35
codescene-access[bot]

This comment was marked as outdated.

@lodyai
lodyai Bot force-pushed the issue-107-minor-structural-overlaps branch from 1f4ce2a to af12c3a Compare July 9, 2026 13:02
codescene-access[bot]

This comment was marked as outdated.

@lodyai
lodyai Bot force-pushed the issue-107-minor-structural-overlaps branch from af12c3a to 8977dad Compare July 9, 2026 13:05
codescene-access[bot]

This comment was marked as outdated.

@lodyai
lodyai Bot force-pushed the issue-107-minor-structural-overlaps branch from 8977dad to 20205cb Compare July 14, 2026 01:31
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.

@lodyai
lodyai Bot force-pushed the issue-107-minor-structural-overlaps branch from db54877 to 8624f6c Compare July 21, 2026 21:18
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai Have the following now been resolved?

tests/unit/publish/test_formatting_helpers.py (1)

19-46: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Delete the duplicate render_section tests from the legacy module.
tests/unit/publish/test_formatting_helpers.py and tests/unit/test_publish_formatting.py now carry the exact same three tests (test_render_section_renders_formatted_items, test_render_section_defaults_to_string_conversion, test_render_section_omits_header_for_empty_sequences), word-for-word. The new module is clearly the canonical home since it also owns the append_section/hypothesis/snapshot coverage — prune the stale copy so the two suites do not drift apart over time.

  • tests/unit/publish/test_formatting_helpers.py#L19-L46: keep as the canonical render_section coverage.
  • tests/unit/test_publish_formatting.py#L17-L44: remove these three duplicate tests (or the whole file, if nothing else remains in it).
🤖 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 @tests/unit/publish/test_formatting_helpers.py around lines 19 - 46, Remove
the duplicate render_section tests from tests/unit/test_publish_formatting.py
lines 17-44, or delete that file if no other tests remain; keep the canonical
test_render_section_renders_formatted_items,
test_render_section_defaults_to_string_conversion, and
test_render_section_omits_header_for_empty_sequences coverage in
tests/unit/publish/test_formatting_helpers.py lines 19-46 unchanged.

@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

ast-grep outline tests/unit/publish/test_formatting_helpers.py --items all --type function
printf '\n--- legacy module ---\n'
ast-grep outline tests/unit/test_publish_formatting.py --items all --type function || true

printf '\n--- canonical test region ---\n'
nl -ba tests/unit/publish/test_formatting_helpers.py | sed -n '1,90p'

printf '\n--- legacy test module ---\n'
nl -ba tests/unit/test_publish_formatting.py | sed -n '1,120p' || true

Length of output: 1869


@leynos Mark this finding as resolved. The three render_section tests remain only in tests/unit/publish/test_formatting_helpers.py; tests/unit/test_publish_formatting.py now contains unrelated formatting tests only.

@leynos

leynos commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai Have the following failed checks now been resolved?

If further work is required, please provide an AI agent prompt for the remaining work to be done to address these failures.

Do not treat warnings as optional or aspirational. Where a change is out of scope for this PR, propose a GitHub issue unless one exists already. (Treat documentation and validation coverage as in scope).

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
User-Facing Documentation ⚠️ Warning The new user-visible publish-plan empty-state output is only covered by tests and developer docs; docs/users-guide.md does not mention it. Add a brief users-guide note for the publish plan output, including the empty-state line 'Crates to publish: none', or remove the output change.
Testing (Unit And Behavioural) ⚠️ Warning The Hypothesis and snapshot unit tests are sound, but the new 'behavioural' test drives private _run_with_context and mocks load_workspace, so it never hits the CLI boundary. Add coverage through cli.main or cli.app with preloaded and disk-loaded config, and assert the public command path yields the same downstream behaviour.

coderabbitai[bot]

This comment was marked as resolved.

codescene-access[bot]

This comment was marked as outdated.

@lodyai
lodyai Bot force-pushed the issue-107-minor-structural-overlaps branch from 14a3443 to d84eefb Compare July 26, 2026 16:19
leynos and others added 5 commits July 26, 2026 18:20
13a: collapse _format_crates_section into the single section renderer.
The bespoke function duplicated _append_section plus an empty message
and a fixed formatter. The renderer is now _render_section, a query
returning the section lines (which also keeps the argument count
within the lint ceiling); _format_plan composes it for every section.
The historical public append_section (listed in __all__) is retained
as a thin backwards-compatible shim that extends the passed-in list by
delegating to _render_section, so existing importers keep working while
new code uses render_section.

13b: catch PublishPreflightError alone in the live pipeline, with a
comment noting that PublishError subclasses it, so the redundant tuple
is not reintroduced by accident.

13c: deduplicate the load-workspace-and-run block in
cli._run_with_context. Configuration scope is resolved first (a
nullcontext when already loaded), then a single block runs the
command.

13d: document that utils.commands.LADING_CATALOGUE is staged but not
yet wired into the execution path, in both the module docstring and
the developers' guide, with a pointer to the roadmap Phase 5 steps
that will wire it.

Tests: property test pins the render_section header/item/empty-message
invariants, unit tests pin the append_section shim (list mutation,
empty no-op, parity with render_section), syrupy snapshots lock the
fully rendered publish plan with and without publishable crates, and a
behavioural test pins identical downstream behaviour for both
_run_with_context branches.

Closes #107
Address two review warnings on the publish-plan/CLI work.

Users' guide: document the publish-plan summary that `lading publish`
prints on completion — the crates-to-publish list, the skipped-crate
sections, and the `Crates to publish: none` empty state — which was
previously covered only by tests and the developers' guide.

CLI-boundary test: add `test_publish_via_app_matches_across_config_branches`,
which drives `cli.app` (the public command boundary) for both
`_run_with_context` configuration branches. `cli.main` always installs
configuration before dispatch, so the disk-loaded branch is reachable
publicly only through `cli.app` without an active scope. The test asserts
identical downstream behaviour (same workspace, equal configuration) while
pinning the provenance difference: the disk branch reloads a fresh config
object; the pre-loaded branch reuses the active one. The white-box
`test_run_with_context_branches_behave_identically` is retained.
Address review comments on the publish-plan/CLI test and docs.

Tests: give the previously bare assertions in the render_section unit
tests focused diagnostic messages — the default-formatting, empty-section,
empty-message, the four property invariants, and both snapshot
assertions — plus the `minimal_config.exists()` setup check in the CLI
config-branch test. Each message states the contract being verified so a
failure explains itself.

Docs: turn the code-formatted `docs/roadmap.md` reference in the
LADING_CATALOGUE / Phase 5 text into a relative Markdown link,
`[Phase 5 runner-migration steps](./roadmap.md)`, matching the guide's
existing relative-link style.
Address review comments on the publish-plan/CLI work.

Tests: give the config-branch tests (`test_run_with_context_branches_
behave_identically`, `test_publish_via_app_matches_across_config_branches`)
and the remaining section-helper tests diagnostic assertion messages, so a
failure names the invariant it checks (result, call count, workspace root,
configuration object, or workspace graph). No test logic changes.

Users' guide: move the `Crates to publish: none` empty-state sentence so it
introduces the empty-case example rather than the populated one.

Developers' guide: document the `publish_plan` section helpers
(`render_section`, `append_section`, `format_plan`) under the extracted
publish modules, and add a "CLI context loading" subsection describing
`_run_with_context` and its single-branch configuration resolution.
Post-rebase reconciliation with main's #176 (plaintext prose fences):
convert the two publish-plan example fences in the users' guide from
`text` to `plaintext` to match the repository convention, and drop a
duplicate blank line that the entity merge left before the new
"CLI context loading" subsection in the developers' guide (MD012).
@lodyai
lodyai Bot force-pushed the issue-107-minor-structural-overlaps branch from d84eefb to bf456eb Compare July 26, 2026 16:20
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 26, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/unit/test_publish_formatting.py (1)

17-42: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Remove the duplicate skipped-section test.

Retain the canonical coverage in
tests/unit/publish/test_formatting_helpers.py and delete this identical test.
As per coding guidelines, “Extract reusable logic, avoid repetition”.

Proposed fix
-def test_format_plan_formats_skipped_sections(
-    tmp_path: Path,
-    make_crate: cabc.Callable[[Path, str, _CrateSpec | None], WorkspaceCrate],
-) -> None:
-    """``format_plan`` renders skipped crates using their names only."""
-    ...
🤖 Prompt for 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.

In `@tests/unit/test_publish_formatting.py` around lines 17 - 42, Delete the
duplicate test_format_plan_formats_skipped_sections test from
tests/unit/test_publish_formatting.py, while retaining the canonical coverage in
test_formatting_helpers.py. Do not modify the canonical test or add replacement
coverage.

Source: Coding guidelines

🤖 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/utils/commands.py`:
- Around line 12-16: Update the migration documentation in the subprocess-runner
context to reference `_invoke_via_subprocess()` in `publish_execution.py` as the
Phase 5.2 target, replacing the incorrect `lading/runtime/subprocess_runner.py`
reference while preserving the existing note that the catalogue is not yet wired
into execution.

---

Outside diff comments:
In `@tests/unit/test_publish_formatting.py`:
- Around line 17-42: Delete the duplicate
test_format_plan_formats_skipped_sections test from
tests/unit/test_publish_formatting.py, while retaining the canonical coverage in
test_formatting_helpers.py. Do not modify the canonical test or add replacement
coverage.
🪄 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: 59dfcff0-4d91-4008-8404-05cb64b678d2

📥 Commits

Reviewing files that changed from the base of the PR and between 8624f6c and bf456eb.

📒 Files selected for processing (10)
  • docs/developers-guide.md
  • docs/users-guide.md
  • lading/cli.py
  • lading/commands/publish.py
  • lading/commands/publish_plan.py
  • lading/utils/commands.py
  • tests/unit/publish/__snapshots__/test_formatting_helpers.ambr
  • tests/unit/publish/test_formatting_helpers.py
  • tests/unit/test_cli.py
  • tests/unit/test_publish_formatting.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/utils/commands.py Outdated
@leynos

leynos commented Jul 26, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai Have the following now been resolved?

tests/unit/publish/test_formatting_helpers.py (1)

19-34: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add failure messages to the newly-written bare asserts.
Several of the rewritten tests still lack diagnostic messages: line 34 (test_render_section_renders_formatted_items), line 59 (test_append_section_extends_list_in_place), line 68 (test_append_section_appends_nothing_when_empty), and lines 82-84 (test_append_section_matches_render_section). Attach a message to each so a failure names the broken contract without needing to re-read the assertion.

🛠️ Proposed fix
-    assert lines == ["Header:", "- ALPHA", "- BETA"]
+    assert lines == ["Header:", "- ALPHA", "- BETA"], (
+        "formatter should be applied to each item under the header"
+    )

As per path instructions, "Use assert …, "message" over bare asserts".
Also applies to: 53-84

🤖 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 @tests/unit/publish/test_formatting_helpers.py around lines 19 - 34, Update
the assertions in test_render_section_renders_formatted_items,
test_append_section_extends_list_in_place,
test_append_section_appends_nothing_when_empty, and
test_append_section_matches_render_section to include concise failure messages
describing the expected rendering or append contract; do not alter the test
logic or expected values.

Source: Path instructions

@coderabbitai

coderabbitai Bot commented Jul 26, 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' '--- test-function outline ---'
ast-grep outline tests/unit/publish/test_formatting_helpers.py --items all --type function

printf '%s\n' '--- relevant assertions ---'
nl -ba tests/unit/publish/test_formatting_helpers.py | sed -n '15,105p'

printf '%s\n' '--- repository instruction files, if present ---'
fd -a -t f -i 'AGENTS.md' -i 'CONTRIBUTING.md' -i '*instruction*' . \
  -E .git -E .venv -E node_modules | head -50

Length of output: 1707


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- relevant assertions ---'
sed -n '15,105p' tests/unit/publish/test_formatting_helpers.py

printf '%s\n' '--- instruction-file candidates ---'
fd -a -t f . -E .git -E .venv -E node_modules \
  | grep -Ei '(^|/)(AGENTS\.md|CONTRIBUTING\.md|.*instructions?.*|.*guidelines?.*)$' \
  | head -50 || true

printf '%s\n' '--- assertion-message guidance ---'
rg -n -i -C 2 'assert.*message|message.*assert|bare assert' \
  --glob 'AGENTS.md' \
  --glob 'CONTRIBUTING.md' \
  --iglob '*instruction*' \
  --iglob '*guideline*' \
  . || true

Length of output: 3903


@leynos Mark this finding as resolved.

tests/unit/publish/test_formatting_helpers.py now attaches concise diagnostic messages to every assertion named in the finding:

  • test_render_section_renders_formatted_items
  • test_append_section_extends_list_in_place
  • test_append_section_appends_nothing_when_empty
  • test_append_section_matches_render_section

The test logic and expected values remain unchanged.

@leynos

leynos commented Jul 26, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

`test_format_plan_formats_skipped_sections` in test_publish_formatting.py
was a behavioural duplicate of the canonical test in
tests/unit/publish/test_formatting_helpers.py (identical assertions on
`format_plan` skipped-section rendering; only the crate-construction
plumbing differed). Remove it and the imports it alone used
(`collections.abc`, `publish_plan`, `_CrateSpec`, `WorkspaceCrate`); the
file keeps its unique `test_format_preparation_summary` coverage.
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

The catalogue-wiring migration target was misrouted to the low-level
`subprocess_runner.py` (and cited a roadmap step that does not exist).
The catalogue's `scoped(allowlist=…)` enforcement is wired in by roadmap
Phase 5.2 "Publish Execution Migration", which rewires
`publish_execution.py`'s command execution (the roadmap's
`_invoke_via_subprocess()` step; `_invoke` today) onto cuprum. Point the
`utils/commands.py` module docstring and the developers' guide note at
that step, keeping the "staged, not yet wired" caveat.

@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/publish.py is usually changed with: lading/tests/bdd/steps/test_publish_steps.py
  • lading/tests/unit/test_cli.py is usually changed with: lading/lading/commands/bump.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.

@buzzybee-df12

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 27, 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.

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.

Minor structural overlaps: section renderer, exception tuple, _run_with_context, catalogue note

3 participants