Skip to content

Upgrade ortho-config to v0.8.0; add global-args loader and tests#188

Merged
leynos merged 19 commits intomainfrom
update-ortho-config-to-v0-8-0-15pjds
Mar 13, 2026
Merged

Upgrade ortho-config to v0.8.0; add global-args loader and tests#188
leynos merged 19 commits intomainfrom
update-ortho-config-to-v0-8-0-15pjds

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Mar 7, 2026

Summary

  • Upgraded ortho_config to v0.8.0 across the workspace; refreshed Cargo.lock and added rust-version = "1.89".
  • Introduced a dedicated global-args loader via a new module: src/config_loader.rs exposing load_global_args_without_cli_overrides(), integrated into runtime to ignore empty CLI inputs.
  • Added unit/integration tests for the loader and global-args flow: load_global_args_without_cli_overrides_defaults_cleanly and tests in src/main_tests.rs and src/test_utils.rs.
  • Expanded documentation including upstream v0.8.0 user guide, migration notes, and execution planning docs; updated README to reference v0.8.0.
  • Updated tests and mocks to ensure global args do not override config when CLI input is absent.

Changes

  • Dependency updates
    • Cargo.toml: ortho_config = "0.8.0" and rust-version = "1.89"; removed unofficial rcdom variant per v0.8.0.
    • Cargo.lock: refreshed to resolve v0.8.0 dependencies.
  • Code changes
    • src/config_loader.rs: New module providing load_global_args_without_cli_overrides().
    • src/main.rs: Integrated loader module; main() now uses config_loader::load_global_args_without_cli_overrides() to compose and merge global layers while ignoring empty CLI inputs.
    • src/main.rs: Added module import for the new loader and adjusted flow accordingly.
    • src/main_tests.rs: Added tests for CLI/global-loader behavior.
    • src/test_utils.rs: Expanded test utilities and local testing scaffolding to support new loader/tests.
    • src/environment.rs: Minor enhancements to environment handling for tests.
  • Miscellaneous
    • Affected tests now include checks ensuring global args do not override config when CLI input is absent.
  • Documentation and guides
    • docs/execplans/adopt-ortho-config-v0-8-0.md: new execplan doc describing upgrade plan.
    • docs/github-token.md: updated guidance changes.
    • docs/ortho-config-users-guide.md: updated to upstream v0.8.0 guide.
    • docs/ortho-config-v0-7-0-migration-guide.md: new v0.7.0 migration guide for reference.
    • docs/vk-design.md: minor alignment updates.
    • docs/vk-end-to-end-testing-guide.md: minor alignment updates.
    • README: v0.8.0 reference updates.
  • Files touched
    • Cargo.lock, Cargo.toml
    • README.md
    • docs/execplans/adopt-ortho-config-v0-8-0.md
    • docs/github-token.md
    • docs/ortho-config-users-guide.md
    • docs/ortho-config-v0-7-0-migration-guide.md
    • docs/vk-design.md
    • docs/vk-end-to-end-testing-guide.md
    • src/config_loader.rs
    • src/main.rs
    • src/main_tests.rs
    • src/test_utils.rs
    • src/environment.rs

Implementation plan (highlights)

  • Update dependency and lockfile; ensure rust-version aligns with v0.8.0 MSRV.
  • Implement global-args loading/merging helper (config_loader) and switch runtime path to use it.
  • Add regression tests for global-defaults-without-CLI-override behaviour.
  • Update repository documentation to reflect upstream v0.8.0 guidance and add migration/execplan notes.
  • Run format, lint, tests, and markdown validation; adjust as needed.

Validation plan

  • Dependency graph checks: cargo tree -i ortho_config
  • Source checks: rg for cli_default_as_absent / SelectedSubcommandMerge / compose_layers
  • YAML/fixtures: ensure YAML 1.2 compatibility and literals don’t break tests
  • Build and tests: make fmt, make lint, make test, make markdownlint; ensure all pass
  • Documentation review: ensure docs reflect v0.8.0 and new migration/execplan notes

Risks and open questions

  • Upstream v0.8.0 may tighten derive/trait bounds; initial compile will reveal required fixes.
  • Documentation and guides now reference upstream v0.8.0 guidance; ensure consistency.
  • If optional doc generation (cargo orthohelp) is desired, scope it explicitly.

Definition of done

  • ortho_config resolves to v0.8.0 everywhere.
  • The application builds and all tests and lint gates pass.
  • The new global-args load/merge helper is implemented and exercised by tests.
  • Documentation reflects the adopted version and includes Execplan and migration notes.

📎 Task: https://www.devboxer.com/task/92612368-d50f-4dea-9386-d5106fc652b5

Add a comprehensive execplan document outlining the steps to upgrade
this repository's ortho-config dependency from v0.6.0 to v0.8.0. The document
includes goals, migration notes, implementation plans, validation checklists,
and risks associated with the upgrade to guide maintainers through the process.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Mar 7, 2026

Reviewer's Guide

Upgrade the project to ortho_config v0.8.0, adjust global configuration loading to preserve file/env precedence when the CLI provides no overrides, and refresh the ortho-config documentation set (user guide, migration guide, and execplan) plus README to match the new version and features.

Sequence diagram for loading global configuration without empty CLI overrides

sequenceDiagram
    actor User
    participant VkMain as vk_main
    participant GlobalArgs
    participant OrthoConfig as ortho_config_runtime
    participant LayerComp as LayerComposition
    participant MergeLayer

    User->>VkMain: run vk
    VkMain->>VkMain: load_global_args_without_cli_overrides()

    VkMain->>GlobalArgs: compose_layers_from_iter(["vk"])
    GlobalArgs-->>VkMain: LayerComposition

    VkMain->>LayerComp: into_parts()
    LayerComp-->>VkMain: layers, errors

    VkMain->>VkMain: create defaults MergeLayer from GlobalArgs::default()

    loop for each layer in layers
        VkMain->>MergeLayer: check provenance()
        alt provenance is Cli
            VkMain->>MergeLayer: into_value()
            alt value is null
                VkMain-->>VkMain: skip this CLI layer
            else value is non-null
                VkMain-->>VkMain: push MergeLayer::cli(value)
            end
        else provenance is not Cli
            VkMain-->>VkMain: push existing layer
        end
    end

    VkMain->>LayerComp: LayerComposition::new(filtered_layers, errors)
    LayerComp-->>VkMain: composition

    VkMain->>GlobalArgs: composition.into_merge_result(GlobalArgs::merge_from_layers)
    GlobalArgs-->>VkMain: OrthoResult<GlobalArgs>

    VkMain-->>User: run with merged GlobalArgs (file/env preserved when CLI empty)
Loading

File-Level Changes

Change Details Files
Upgrade ortho_config and related dependencies, including setting an explicit Rust MSRV, to target the v0.8.0 release.
  • Bump the ortho_config dependency from 0.6.0 to 0.8.0 in the main crate manifest.
  • Remove the "+unofficial" suffix from the markup5ever_rcdom dependency version.
  • Add rust-version = "1.88" to the crate manifest to declare the minimum supported Rust version.
  • Regenerate Cargo.lock so all dependency versions (including ortho_config transitive deps) match the new constraints.
Cargo.toml
Cargo.lock
Refine how global configuration is loaded so an empty CLI layer does not override configuration file or environment values while still using ortho_config v0.8.0 APIs.
  • Introduce a helper that uses GlobalArgs::compose_layers_from_iter to build a LayerComposition, inject an explicit defaults layer, and filter out null CLI layers before merging.
  • Update main execution flow to load GlobalArgs via the new helper instead of load_from_iter over argv[0].
  • Keep the subsequent merge of parsed CLI globals into the loaded GlobalArgs structure unchanged so CLI-specified values still take precedence when present.
  • Add a serial unit test to assert that, with no relevant environment variables set, the helper produces a GlobalArgs where all optional fields are None and that environment variables are restored after the test.
src/main.rs
Align project documentation with ortho_config v0.8.0 by replacing the local user guide with the upstream v0.8.0 content, adding a v0.7.0 migration guide and an execplan for this upgrade, and updating the README version reference.
  • Replace docs/ortho-config-users-guide.md with the upstream v0.8.0 user guide, including new sections on layer composition, post-merge hooks, localization, clap default handling, selected-subcommand merging, error categorization, and documentation metadata.
  • Add docs/ortho-config-v0-7-0-migration-guide.md to capture the official v0.6.0→v0.7.0 migration steps and context, including compose_layers, PostMergeHook, localization, cli_default_as_absent, and error-handling updates.
  • Add docs/execplans/adopt-ortho-config-v0-8-0.md describing the rationale, implementation plan, validation steps, and risks for upgrading this repository to ortho_config v0.8.0.
  • Update README.md to state that vk now uses OrthoConfig v0.8.0 instead of v0.6.0 and keep the surrounding configuration description intact.
README.md
docs/ortho-config-users-guide.md
docs/ortho-config-v0-7-0-migration-guide.md
docs/execplans/adopt-ortho-config-v0-8-0.md

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8601c0bf-15f2-400d-b2bc-8e217b991f93

📥 Commits

Reviewing files that changed from the base of the PR and between f7874d3 and 0f02372.

📒 Files selected for processing (2)
  • src/config_loader.rs
  • src/test_utils.rs

Summary by CodeRabbit

  • New Features

    • Global config loading now ignores empty CLI flags so file/env values aren’t overwritten; adds safer environment helpers and sandboxed test isolation.
  • Dependencies

    • ortho-config upgraded to v0.8.0.
    • Minimum Rust toolchain set to 1.89.
    • Cleaned up markup5ever_rcdom reference.
  • Documentation

    • Added migration guides, user guide updates and execplan for ortho-config v0.8.0.
  • Tests

    • Expanded entry-point tests and improved test environment isolation.

Walkthrough

Summarise crate upgrade to ortho-config v0.8.0; add a dedicated config loader that composes layers while ignoring null CLI overrides; introduce environment-safe test utilities and separate test modules; add extensive docs and migration guides; remove in-file tests and expose standalone test modules.

Changes

Cohort / File(s) Summary
Manifest & Metadata
Cargo.toml, README.md
Add rust-version = "1.89"; bump ortho_config 0.6.00.8.0; normalise markup5ever_rcdom version; update README references to v0.8.0.
Adoption & Migration Plans
docs/execplans/adopt-ortho-config-v0-8-0.md, docs/ortho-config-v0-7-0-migration-guide.md
Add an execplan for v0.8.0 and a v0.7.0 migration guide outlining upgrade steps, validation checklist and definition of done (docs-only).
User Guide & API Docs
docs/ortho-config-users-guide.md, docs/ortho-config-v0-6-0-migration-guide.md
Rewrite user guide to document new merging primitives, PostMergeHook, Localizer APIs, cargo-orthohelp IR/workflow and updated merge semantics; reformat migration guide anchors/tables (docs-only).
Operational Docs
docs/github-token.md, docs/vk-design.md, docs/vk-end-to-end-testing-guide.md
Apply formatting and clarity edits: add mdformat guards, normalise list numbering, UX additions (resolve-threads), table/header reflow and code/citation adjustments (presentation-only).
Config Loading Refactor
src/config_loader.rs, src/main.rs
Add load_global_args_without_cli_overrides() to construct layers and drop null CLI overrides before merging; update main.rs to call the new loader and import ortho_config::SubcmdConfigMerge; remove large in-file test module and expose #[cfg(test)] mod main_tests;.
Tests & Test Utilities
src/main_tests.rs, src/test_utils.rs, src/environment.rs
Add src/main_tests.rs with extensive CLI and rendering tests; add EnvSandbox and EnvGuard RAII helpers plus global test lock; add var_os returning OsString; consolidate environment isolation helpers and update imports.
New Documentation: Adoption Plan
docs/execplans/adopt-ortho-config-v0-8-0.md
Add large doc describing the full migration implementation plan, validation commands, quality gates and definition of done (docs-only).

Sequence Diagram(s)

sequenceDiagram
  participant CLI as "CLI / argv"
  participant Loader as "config_loader::load_global_args_without_cli_overrides()"
  participant LayerComp as "LayerComposition"
  participant Ortho as "ortho_config::merge"
  participant App as "main (vk)"

  CLI->>Loader: provide argv (including --config-path, subcommand tokens)
  Loader->>LayerComp: compose_layers_from_iter(defaults, files, env, CLI)
  LayerComp-->>Loader: composed layers
  Loader->>LayerComp: filter out null/empty CLI layer
  LayerComp->>Ortho: merge_from_layers(filtered)
  Ortho-->>Loader: GlobalArgs result
  Loader-->>App: supply GlobalArgs
  App->>Ortho: perform SubcmdConfigMerge and execute command
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

Layers align, let CLI not erase,
Ortho climbs onward to v0.8's place 🌿
Sandboxed tests guard each fragile part,
Docs and plans map every migration chart,
Merge, validate, then ship with grace.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the primary changes: upgrading ortho-config to v0.8.0 and introducing a global-args loader with tests.
Description check ✅ Passed The description comprehensively covers the changeset, including dependency updates, code changes, documentation updates, and testing additions with clear implementation and validation plans.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-ortho-config-to-v0-8-0-15pjds
📝 Coding Plan
  • Generate coding plan for human review comments

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

- Replace local ortho-config user guide with upstream v0.8.0 guide
- Apply v0.7.0 and v0.8.0 migration notes relevant to this repo
- Update docs to reflect ortho-config v0.8.0 migration
- Reconcile local docs to avoid contradictions with imported guide
- Outline detailed implementation plan for migration steps
- Highlight risks and necessary validation checks

This commit prepares project documentation and migration planning
for upgrading ortho-config dependency from v0.6.0 to v0.8.0, ensuring
alignment with upstream changes and smoother transition.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
…LI flattening overrides

- Extracted `load_global_args_without_cli_overrides` to compose global config layers and filter empty CLI layers.
- Prevent empty CLI flatten group from overwriting file/env defaults during global config load.
- Updated main to use this new loader for merging global and CLI args.
- Added test ensuring defaults load cleanly without unwanted CLI overrides.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos leynos changed the title Upgrade ortho-config to v0.8.0 and align docs Upgrade ortho-config to v0.8.0; add execplan and migration guides Mar 7, 2026
@leynos leynos marked this pull request as ready for review March 7, 2026 11:22
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docs/ortho-config-users-guide.md" line_range="361" />
<code_context>
+
+### FAQ: should `figment`, `uncased`, or `xdg` be direct dependencies?
+
+No for derive-generated code. Yes, only when application code directly imports
+those crates without going through the `ortho_config::` re-exports.
+
</code_context>
<issue_to_address>
**suggestion (review_instructions):** The phrase "when application code directly imports" is fine, but nearby text in this new section later uses "let you"/"you"; those should be rephrased to avoid 2nd-person pronouns.

In this added block, later sentences such as "let you merge the chosen subcommand" and "let you attribute JSON parsing failures" introduce 2nd-person pronouns, which the style guide forbids. Please rephrase those occurrences, for example:
- "…that enable merging the chosen subcommand…" instead of "let you merge the chosen subcommand".
- "…that enable attribution of JSON parsing failures…" instead of "let you attribute JSON parsing failures…".

<details>
<summary>Review instructions:</summary>

**Path patterns:** `**/*.md`

**Instructions:**
Avoid 2nd person or 1st person pronouns ("I", "you", "we").

</details>
</issue_to_address>

### Comment 2
<location path="docs/ortho-config-v0-7-0-migration-guide.md" line_range="51" />
<code_context>
+
+1. Update every `ortho_config` and `ortho_config_macros` dependency to `0.7.0`.
+1. Keep format features (`toml`, `json5`, `yaml`) on `ortho_config` as before.
+1. If you disable default features, enable `serde_json` explicitly when you
+   want `cli_default_as_absent` or selected-subcommand merging helpers. The
+   default feature set already enables it.
</code_context>
<issue_to_address>
**suggestion (review_instructions):** This list item uses "you" twice and needs to be rephrased to avoid 2nd-person pronouns.

To comply with the pronoun rule, consider rephrasing along the lines of:

> 1. When default features are disabled, enable `serde_json` explicitly whenever `cli_default_as_absent` or selected-subcommand merging helpers are required.

This keeps the instruction but removes direct address to the reader.

<details>
<summary>Review instructions:</summary>

**Path patterns:** `**/*.md`

**Instructions:**
Avoid 2nd person or 1st person pronouns ("I", "you", "we").

</details>
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread docs/ortho-config-users-guide.md
Comment thread docs/ortho-config-v0-7-0-migration-guide.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/execplans/adopt-ortho-config-v0-8-0.md`:
- Around line 29-31: Update the paragraph to correct the Rust version reference
for ortho_config v0.8.0: replace the incorrect "Rust 1.88" phrasing with the
actual minimum Rust version required by ortho_config v0.8.0 (or explicitly mark
it as a forward-looking/unstable requirement pending the Rust 1.88 release), and
mention the repo already using a recent nightly via `rust-toolchain.toml` and
that the crate manifest currently lacks a `rust-version` field so readers know
where the requirement is enforced.
- Around line 101-103: Update the note about adding `rust-version = "1.88"` in
the Cargo.toml guidance: explicitly state that Rust 1.88 is not yet released and
either (A) change the recommendation to the current stable toolchain version
that meets requirements (e.g., the current stable release) or (B) keep
`rust-version` in the plan but document that the manifest entry `rust-version =
"1.88"` will be added only once Rust 1.88 is officially released; ensure this
clarification appears next to the existing Cargo.toml / `rust-version = "1.88"`
line in the adopt-ortho-config-v0-8-0.md plan.

In `@docs/ortho-config-users-guide.md`:
- Line 1015: Update the wording in the sentence containing "When a user passes
`--help` or `--version`, `clap` surfaces specialised" to use en-GB-oxendict
spelling: replace "specialised" with "specialized". Locate this exact phrase in
docs/ortho-config-users-guide.md and make the single-word substitution so the
sentence reads "...`clap` surfaces specialized".

In `@docs/ortho-config-v0-7-0-migration-guide.md`:
- Line 86: Change the heading text "Example: normalise a derived field" to use
American/Oxford spelling "normalize" (i.e., "Example: normalize a derived
field") and search the same document for any other occurrences of "normalise" to
update them to "normalize" for consistency.
- Line 12: Update the document to use the en-GB-oxendict spelling by replacing
instances of "Localise" with "Localize" in headings and body text (e.g., change
the heading "Localise CLI copy and errors" to "Localize CLI copy and errors")
and scan for any other occurrences of "localise" (case-insensitive) to correct
them consistently throughout the file.
- Around line 188-223: Footnote lines like "\[^deps-0-7\]:",
"\[^compose-layers\]:", "\[^post-merge\]:", etc. contain escaped brackets which
break GFM footnote rendering; remove the backslashes before the opening square
bracket for all footnote entries in this section (e.g. change "\[^deps-0-7\]:
v0.7.0 ..." to "[^deps-0-7]: v0.7.0 ..." and apply the same fix for each
footnote token shown in the diff such as ^compose-layers, ^post-merge,
^localizer, ^localizeclap, ^cli-defaults, ^selectedsubcommand, ^display-request,
^json-merge, and ^rstest-bdd).

In `@src/main.rs`:
- Around line 183-185: The call to
serde_json::to_value(GlobalArgs::default()).expect(...) must not use expect;
propagate the serialization error instead: change the surrounding function to
return a Result (or convert the error into the function's existing error type)
and replace the .expect(...) with the ? operator (or a map_err(...) to convert
serde_json::Error), then push the resulting Value into filtered_layers via
MergeLayer::defaults(Cow::Owned(...)); update the function signature and any
callers as needed to handle the propagated error.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: aeead8b7-375e-44c1-bda7-95885bded441

📥 Commits

Reviewing files that changed from the base of the PR and between a9e7495 and cd84b38.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • Cargo.toml
  • README.md
  • docs/execplans/adopt-ortho-config-v0-8-0.md
  • docs/ortho-config-users-guide.md
  • docs/ortho-config-v0-7-0-migration-guide.md
  • src/main.rs

Comment thread docs/execplans/adopt-ortho-config-v0-8-0.md Outdated
Comment thread docs/execplans/adopt-ortho-config-v0-8-0.md Outdated
Comment thread docs/ortho-config-users-guide.md Outdated
Comment thread docs/ortho-config-v0-7-0-migration-guide.md Outdated
Comment thread docs/ortho-config-v0-7-0-migration-guide.md Outdated
Comment thread docs/ortho-config-v0-7-0-migration-guide.md Outdated
Comment thread src/main.rs Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd84b38b3d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main.rs Outdated
Refined phrasing in the ortho-config users guide to enhance clarity and readability in sections describing CLI flag renaming, file discovery, and config path override behavior.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
- Added setup of temporary config sandbox directories in tests.
- Preserved and restored original environment variables to prevent side effects.
- Enhanced test isolation for loading global args without CLI overrides.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos leynos changed the title Upgrade ortho-config to v0.8.0; add execplan and migration guides Upgrade ortho-config to v0.8.0; add global-args merge helper and docs Mar 7, 2026
…ocalization

- Refine v0.6.0 and v0.7.0 migration guides with corrected markdown and improved links
- Clarify Rust MSRV bump to 1.89 in Cargo.toml and docs
- Improve vk design and end-to-end testing guides formatting and content
- Fix typos and unify US/UK English ('localise' to 'localize') in migration guide
- Enhance github-token.md steps for clarity and consistency
- Add references and format work cited section in tests documentation

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@coderabbitai coderabbitai Bot added the codex label Mar 7, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

♻️ Duplicate comments (1)
docs/ortho-config-v0-7-0-migration-guide.md (1)

188-226: ⚠️ Potential issue | 🟡 Minor

Use real footnote definitions here.

Remove the escapes before each [^…]: token. The current form breaks every footnote reference in the guide. As per coding guidelines, **/*.md: Use GitHub-flavoured Markdown style for footnotes and endnotes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/ortho-config-v0-7-0-migration-guide.md` around lines 188 - 226, The
footnote markers are escaped (e.g. \[^deps-0-7\], \[^compose-layers\],
\[^post-merge\], etc.), which breaks GitHub-flavored Markdown footnotes; remove
the leading backslashes before each [^…]: definition and any in-text references
so the tokens are plain [^deps-0-7], [^compose-layers], [^post-merge],
[^localizer], [^localizeclap], [^cli-defaults], [^selectedsubcommand],
[^display-request], [^json-merge], [^rstest-bdd] to restore proper footnote
rendering across the document.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/execplans/adopt-ortho-config-v0-8-0.md`:
- Around line 74-76: Replace the British/Oxford misspelling in the sentence
"Post-merge hooks and localisation: the v0.7.0 guide makes these available…" by
changing "localisation" to "localization" (also update the same word at the
other occurrence referenced around lines 120-121); ensure both occurrences use
"localization" to conform to the repo's en-GB-oxendict (-ize) convention and
keep surrounding punctuation/capitalization unchanged.

In `@docs/github-token.md`:
- Around line 8-12: The ordered list in docs/github-token.md uses repeated "1."
which triggers markdownlint MD029; update the four list items so they are
numbered 2., 3., 4., and 5. (Keep the same item text: "Give the token a
note...", "Under Select scopes...", "Click Generate token...", "Export the token
as VK_GITHUB_TOKEN...") This will satisfy markdownlint and the repository's
Markdown validation.

In `@docs/ortho-config-users-guide.md`:
- Around line 586-618: The ordered lists in the documentation use repeated "1."
entries which triggers MD029; update each ordered list block so numbering is
sequential (1., 2., 3., ...) instead of repeating "1." — specifically fix the
list starting with "Attempts to load a configuration file." (and the subsequent
lists that begin "Adds an environment provider..." and "Adds a provider
containing the CLI values...") as well as the other occurrences noted (the
blocks referred to as 669-676, 961-964, 1190-1199) so every list item uses
correct incremental numbers to satisfy markdownlint.
- Around line 276-283: The derive macro path in the example is incorrect: change
uses of ortho_config_macros::SelectedSubcommandMerge to the re-exported path
ortho_config::SelectedSubcommandMerge so the derive matches the public API and
the listed dependency ortho_config; update all occurrences of the derive (e.g.,
the derive on the type that implements SelectedSubcommandMerge and any examples
between 856–889) to use ortho_config::SelectedSubcommandMerge and ensure
Cargo.toml only requires ortho_config (not ortho_config_macros).
- Around line 441-447: Update the documentation for the merge_strategy attribute
to list all supported strategies in v0.8.0 ("append", "replace", "keyed"),
explain their constraints and defaults: "append" concatenates Vec<T> values and
is the default for vector fields, "keyed" merges map-like types and is the
default for maps, and "replace" (available for both vectors and maps) makes the
later source override previous values; ensure the entry for merge_strategy
mentions these three options and that append is not the only strategy.

In `@docs/ortho-config-v0-6-0-migration-guide.md`:
- Around line 223-257: The footnote definitions are currently escaped (e.g.,
"\[^forwarded-features\]:", "\[^hello-world-cargo\]:", "\[^reexports\]:", etc.),
causing them to render as plain text; remove the leading backslashes before each
footnote token so they appear as real GitHub-flavored Markdown footnote
definitions (e.g., change "\[^forwarded-features\]:" to
"[^forwarded-features]:") and do the same for every other escaped footnote token
in that block to restore proper footnote rendering.

In `@docs/vk-design.md`:
- Around line 70-71: Remove the escaped backslashes from the footnote definition
so the GitHub-flavored footnote resolves: replace the literal
"\[^github-link\]:" with an unescaped "[^github-link]:" in the docs/vk-design.md
footnote block (the footnote label [^github-link] must exactly match the
reference used earlier), ensuring the URL and description remain on the
following line.

In `@docs/vk-end-to-end-testing-guide.md`:
- Around line 247-251: Update the ordered lists in
docs/vk-end-to-end-testing-guide.md to use sequential numbering instead of
repeated "1." for each item: renumber the block containing "Cargo's test runner
can find and compile the `tests/e2e.rs` file.", "`assert_cmd` is able to locate
the `vk` binary produced by the build process.", and "The basic assertion
mechanism is working as expected." to 1., 2., 3. respectively (and apply the
same fix to the other affected section referenced around lines 635-699). Ensure
the list prefixes are sequential so Markdownlint MD029 no longer triggers and
re-run make markdownlint to verify.
- Around line 1018-1101: Remove the erroneous backslashes before each footnote
definition (e.g., change "\[^1\]:" to "[^1]:") and rewrite any bare fenced code
URL blocks into the footnote line itself (e.g., replace the fenced
"```<https://docs.rs/termimad>```" and
"```<https://github.com/assert-rs/assert_cmd>```" with inline URLs in the
corresponding footnotes such as "[^4]: <https://docs.rs/termimad>" and "[^10]:
<https://github.com/assert-rs/assert_cmd>"). Ensure all footnotes [^1] through
[^25] use GitHub-flavored Markdown footnote syntax with the URL folded into the
footnote text and no surrounding triple-backtick fences.

In `@src/main.rs`:
- Around line 179-199: The helper load_global_args_without_cli_overrides
currently composes layers from a synthetic single-arg iterator
(OsString::from("vk")), which drops CLI-only discovery inputs (e.g. generated
config-path overrides); change it to pass the real argv (or ArgMatches) into
GlobalArgs::compose_layers_from_iter so the actual CLI-provided values are
included, then when iterating the composed layers only remove or skip the
empty/placeholder CLI layer (check MergeProvenance::Cli and use
layer.into_value().is_null() to detect emptiness) rather than constructing a
fake "vk" layer; this preserves CLI-only discovery inputs so
LayerComposition::new(...).into_merge_result(GlobalArgs::merge_from_layers) can
honor explicit config-path overrides.

---

Duplicate comments:
In `@docs/ortho-config-v0-7-0-migration-guide.md`:
- Around line 188-226: The footnote markers are escaped (e.g. \[^deps-0-7\],
\[^compose-layers\], \[^post-merge\], etc.), which breaks GitHub-flavored
Markdown footnotes; remove the leading backslashes before each [^…]: definition
and any in-text references so the tokens are plain [^deps-0-7],
[^compose-layers], [^post-merge], [^localizer], [^localizeclap],
[^cli-defaults], [^selectedsubcommand], [^display-request], [^json-merge],
[^rstest-bdd] to restore proper footnote rendering across the document.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bfb40dec-3804-469e-9fb5-ba21adc97db1

📥 Commits

Reviewing files that changed from the base of the PR and between cd84b38 and 74f6e0b.

📒 Files selected for processing (9)
  • Cargo.toml
  • docs/execplans/adopt-ortho-config-v0-8-0.md
  • docs/github-token.md
  • docs/ortho-config-users-guide.md
  • docs/ortho-config-v0-6-0-migration-guide.md
  • docs/ortho-config-v0-7-0-migration-guide.md
  • docs/vk-design.md
  • docs/vk-end-to-end-testing-guide.md
  • src/main.rs

Comment thread docs/execplans/adopt-ortho-config-v0-8-0.md Outdated
Comment thread docs/github-token.md
Comment thread docs/ortho-config-users-guide.md
Comment thread docs/ortho-config-users-guide.md
Comment thread docs/ortho-config-users-guide.md
Comment thread docs/ortho-config-v0-6-0-migration-guide.md Outdated
Comment thread docs/vk-design.md
Comment thread docs/vk-end-to-end-testing-guide.md
Comment thread docs/vk-end-to-end-testing-guide.md
Comment thread src/main.rs Outdated
…th overrides

This refactor updates the global configuration loading process to accurately parse and honor the --config-path discovery override from the process arguments. It excludes subcommand tokens that GlobalArgs cannot parse, preventing empty CLI flatten groups from overwriting file or environment values. Additional helper functions and tests enhance configuration precedence handling and maintain backward compatibility.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

Caution

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

⚠️ Outside diff range comments (1)
docs/ortho-config-v0-6-0-migration-guide.md (1)

51-60: ⚠️ Potential issue | 🟡 Minor

Renumber this ordered list.

Use sequential prefixes here. Repeating 1. trips MD029 in this repo, so
make markdownlint will fail.

As per coding guidelines, "**/*.md: Validate Markdown with make markdownlint".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/ortho-config-v0-6-0-migration-guide.md` around lines 51 - 60, The
ordered list in the migration guide uses repeated "1." markers which triggers
MD029; update the three list entries so their prefixes are sequential (1., 2.,
3.) instead of all "1.", preserving the exact text for each item (references to
`ortho_config`, `ortho_config_macros`, feature names like `json5`, `yaml`,
`toml`, and the rebuild step) to satisfy markdownlint and keep content
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/execplans/adopt-ortho-config-v0-8-0.md`:
- Around line 103-106: The docs currently duplicate the action to add
rust-version = "1.89"; change this paragraph so it is a verification step
instead of an add step (i.e., instruct the reader to confirm that rust-version =
"1.89" is present in Cargo.toml and matches ortho_config v0.8.0 MSRV), or
alternatively update the earlier "current state" text to state that rust-version
is not present so the later add step is valid; ensure the final text only
verifies presence or clearly states that the manifest needs to be updated to
rust-version = "1.89" to avoid duplicate instructions.

In `@docs/ortho-config-users-guide.md`:
- Around line 856-889: The example currently fails to compile because the
placeholder tuple types GreetArgs and RunArgs do not implement clap::Args
required by the #[derive(Subcommand)] on enum Commands; either add the clap
derive to those placeholders (e.g., derive Parser/Args on GreetArgs and RunArgs
so they satisfy Subcommand) or mark the code block as non-compiling by changing
the fence to rust,ignore to indicate it’s illustrative only; update whichever of
GreetArgs, RunArgs, or the code fence accordingly so the documentation builds or
clearly shows it’s non-compiling.

In `@docs/ortho-config-v0-6-0-migration-guide.md`:
- Around line 225-267: The footnote block references repository links tagged
v0.8.0 (e.g., URLs in the notes for [^forwarded-features], [^hello-world-cargo],
[^reexports], [^hello-world-figment], [^discovery-attr],
[^hello-world-discovery], [^discovery-errors], [^hello-world-discover-config],
[^saphyr], [^hello-world-yaml], [^changelog]) but the guide targets the v0.6.0
migration; update every occurrence of "v0.8.0" in these footnote URLs and link
texts to "v0.6.0" so the citations point to the correct tag, applying the same
tag change consistently across the entire footnote block.

In `@docs/ortho-config-v0-7-0-migration-guide.md`:
- Around line 49-56: Renumber the ordered list so the first item stays "1." and
the subsequent items use "2.", "3.", and "4." instead of repeating "1."; update
the lines that begin "Keep format features (`toml`, `json5`, `yaml`)...", "If
you disable default features, enable `serde_json` explicitly...", and "Expect
new transitive dependencies (`fluent-bundle`, `fluent-syntax`, `unic-langid`,
and `tracing`)..." to start with "2.", "3.", and "4." respectively to satisfy
MD029 and avoid markdownlint failures.
- Around line 188-226: Update the footnote links in the cited footnote block by
changing every reference that points to the v0.8.0 tag to the v0.7.0 tag;
specifically edit the URLs referenced in footnotes [^deps-0-7],
[^compose-layers], [^post-merge], [^localizer], [^localizeclap],
[^cli-defaults], [^selectedsubcommand], [^display-request], [^json-merge], and
[^rstest-bdd] so the GitHub links end with /blob/v0.7.0/... instead of
/blob/v0.8.0/.... Ensure all occurrences in that footnote block are changed
consistently.

In `@docs/vk-design.md`:
- Around line 79-82: The ordered list items are all numbered `1.` which trips
MD029; update the second and third entries so the list reads "1.
write_comment_body...", "2. write_comment...", "3. write_thread..." instead of
repeating `1.`; locate the list in docs/vk-design.md referencing the symbols
write_comment_body, write_comment, and write_thread and change the numeric
markers for the second and third lines accordingly so Markdown lint passes.

In `@src/main.rs`:
- Around line 233-236: Reformat the construction of filtered so it satisfies
rustfmt: break the long vec![args.next().map_or_else(|| OsString::from("vk"),
Into::into)] expression across lines and add the necessary commas/spacing so
cargo fmt passes; specifically adjust the expression that initializes filtered
(the vec![ ... ] containing args.next().map_or_else(...)]), keeping the same
logic (use map_or_else with OsString::from("vk") and Into::into) and then run
rustfmt (cargo fmt --all) to verify.
- Around line 204-223: The code is prepending a defaults layer despite
GlobalArgs::compose_layers_from_iter already including defaults; remove the
manual insertion of MergeLayer::defaults (the push of
MergeLayer::defaults(Cow::Owned(default_globals))) and rely on the composition
returned by GlobalArgs::compose_layers_from_iter, adjusting filtered_layers
initialization accordingly; also remove the now-unused OrthoJsonMergeExt import
to clean up unused imports referenced in the file.

---

Outside diff comments:
In `@docs/ortho-config-v0-6-0-migration-guide.md`:
- Around line 51-60: The ordered list in the migration guide uses repeated "1."
markers which triggers MD029; update the three list entries so their prefixes
are sequential (1., 2., 3.) instead of all "1.", preserving the exact text for
each item (references to `ortho_config`, `ortho_config_macros`, feature names
like `json5`, `yaml`, `toml`, and the rebuild step) to satisfy markdownlint and
keep content unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bebb91dd-4a3b-4bbf-92fe-9b152895b5ee

📥 Commits

Reviewing files that changed from the base of the PR and between 74f6e0b and 4e9c44e.

📒 Files selected for processing (8)
  • docs/execplans/adopt-ortho-config-v0-8-0.md
  • docs/github-token.md
  • docs/ortho-config-users-guide.md
  • docs/ortho-config-v0-6-0-migration-guide.md
  • docs/ortho-config-v0-7-0-migration-guide.md
  • docs/vk-design.md
  • docs/vk-end-to-end-testing-guide.md
  • src/main.rs

Comment thread docs/execplans/adopt-ortho-config-v0-8-0.md Outdated
Comment thread docs/ortho-config-users-guide.md
Comment thread docs/ortho-config-v0-6-0-migration-guide.md Outdated
Comment thread docs/ortho-config-v0-7-0-migration-guide.md
Comment thread docs/ortho-config-v0-7-0-migration-guide.md Outdated
Comment thread docs/vk-design.md
Comment thread src/main.rs Outdated
Comment thread src/main.rs Outdated
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Mar 7, 2026

@coderabbitai Have the following now been resolved?

Annul any requirements that violate the en-GB-oxendict spelling (-ize / -yse / -our) conventions (for example a request to replace "normalize" with "normalise" or "artefact" with "artifact"), or where the requirement unnecessarily increases cyclomatic complexity.

Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docs/ortho-config-users-guide.md" line_range="361" />
<code_context>
+
+### FAQ: should `figment`, `uncased`, or `xdg` be direct dependencies?
+
+No for derive-generated code. Yes, only when application code directly imports
+those crates without going through the `ortho_config::` re-exports.
+
</code_context>
<issue_to_address>
**suggestion (review_instructions):** The phrase "when application code directly imports" is fine, but nearby text in this new section later uses "let you"/"you"; those should be rephrased to avoid 2nd-person pronouns.

In this added block, later sentences such as "let you merge the chosen subcommand" and "let you attribute JSON parsing failures" introduce 2nd-person pronouns, which the style guide forbids. Please rephrase those occurrences, for example:
- "…that enable merging the chosen subcommand…" instead of "let you merge the chosen subcommand".
- "…that enable attribution of JSON parsing failures…" instead of "let you attribute JSON parsing failures…".

<details>
<summary>Review instructions:</summary>

**Path patterns:** `**/*.md`

**Instructions:**
Avoid 2nd person or 1st person pronouns ("I", "you", "we").

</details>
</issue_to_address>

### Comment 2
<location path="docs/ortho-config-v0-7-0-migration-guide.md" line_range="51" />
<code_context>
+
+1. Update every `ortho_config` and `ortho_config_macros` dependency to `0.7.0`.
+1. Keep format features (`toml`, `json5`, `yaml`) on `ortho_config` as before.
+1. If you disable default features, enable `serde_json` explicitly when you
+   want `cli_default_as_absent` or selected-subcommand merging helpers. The
+   default feature set already enables it.
</code_context>
<issue_to_address>
**suggestion (review_instructions):** This list item uses "you" twice and needs to be rephrased to avoid 2nd-person pronouns.

To comply with the pronoun rule, consider rephrasing along the lines of:

> 1. When default features are disabled, enable `serde_json` explicitly whenever `cli_default_as_absent` or selected-subcommand merging helpers are required.

This keeps the instruction but removes direct address to the reader.

<details>
<summary>Review instructions:</summary>

**Path patterns:** `**/*.md`

**Instructions:**
Avoid 2nd person or 1st person pronouns ("I", "you", "we").

</details>
</issue_to_address>

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 7, 2026

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== docs/ortho-config-users-guide.md: searching for 'let you' ==="
rg -n "let you" docs/ortho-config-users-guide.md || echo "NOT FOUND"

echo ""
echo "=== docs/ortho-config-v0-7-0-migration-guide.md: searching for second-person pronouns ==="
rg -n "\byou\b|\bIf you\b|\bwhen you\b" docs/ortho-config-v0-7-0-migration-guide.md || echo "NOT FOUND"

echo ""
echo "=== Context around line 51 of migration guide ==="
sed -n '45,60p' docs/ortho-config-v0-7-0-migration-guide.md

echo ""
echo "=== Context around line 355-375 of users guide ==="
sed -n '355,380p' docs/ortho-config-users-guide.md

Length of output: 2806


@leynos: Here is the current status of the two comments:

Comment File Status
1 — "let you merge" / "let you attribute" docs/ortho-config-users-guide.md ✅ Resolved — neither phrase is present
2 — "If you disable" / "when you want" docs/ortho-config-v0-7-0-migration-guide.md ❌ Not resolved — line 51 is unchanged

The text at line 51 of the migration guide still reads:

1. If you disable default features, enable `serde_json` explicitly when you
   want `cli_default_as_absent` or selected-subcommand merging helpers.

Rephrase it to remove the second-person address, e.g.:

1. When default features are disabled, enable `serde_json` explicitly whenever
   `cli_default_as_absent` or selected-subcommand merging helpers are required.

As a side note, there are further second-person occurrences in the same file (lines 75, 159, 180, 184) that also breach the style rule — they fall outside the originally flagged range but warrant attention.

Corrected the ordered lists numbering in v0.6.0 and v0.7.0 migration guides
for clarity. Updated version number references from v0.8.0 to the
appropriate v0.6.0 or v0.7.0 in documentation links to maintain accuracy.

Also improved some wording for better clarity in execplans and user guide
examples.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Mar 8, 2026

@coderabbitai review

@coderabbitai

This comment was marked as resolved.

- Extracted parse_resolve_args helper to simplify CLI resolve command parsing in tests.
- Rewrote existing resolve_subcommand_parses and resolve_subcommand_parses_message tests to use this helper.
- Removed unused rstest dependency and EnvGuard struct.
- Improved invalid VK_HTTP_TIMEOUT error test setup and cleanup with a closure-based helper.
- Changed several tests to use a unified approach for creating and asserting errors.
- Minor cleanup and formatting in vk-design.md unrelated to testing.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (3)
docs/vk-design.md (2)

70-78: ⚠️ Potential issue | 🟡 Minor

Remove the escaped brackets in the footnote definition.

The escaped \[^github-link\]: on line 72 renders as literal text, so the footnote reference on line 32 will not resolve. Remove the backslashes to enable GitHub-flavoured footnote linking.

🛠️ Proposed fix
 <!-- mdformat off -->

-\[^github-link\]: GitHub Docs. "Linking to a pull request comment."
+[^github-link]: GitHub Docs. "Linking to a pull request comment."

 <!-- markdownlint-disable-next-line MD013 -->

As per coding guidelines, "**/*.md: Use GitHub-flavoured Markdown footnotes ([^1]) for references".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/vk-design.md` around lines 70 - 78, The footnote definition is escaped
as "\[^github-link\]:", preventing the footnote from resolving; update the
footnote label by removing the backslashes so it reads "[^github-link]: GitHub
Docs. \"Linking to a pull request comment.\"" (leave the URL and surrounding
mdformat directives intact) so the inline reference [^github-link] resolves
correctly.

86-91: ⚠️ Potential issue | 🟡 Minor

Renumber the ordered list to pass MD029.

The list items are all numbered 1. which triggers MD029 (ordered list item prefix). Markdownlint expects 1/2/3 style numbering.

🛠️ Proposed fix
 <!-- mdformat off -->

 1. `write_comment_body` formats a single comment body to any `Write`
    implementation.
-1. `write_comment` includes the diff for the first comment in a thread.
-1. `write_thread` iterates over a thread and prints each comment body in turn.
+2. `write_comment` includes the diff for the first comment in a thread.
+3. `write_thread` iterates over a thread and prints each comment body in turn.

 <!-- mdformat on -->

As per coding guidelines, "**/*.md: Validate Markdown with make markdownlint".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/vk-design.md` around lines 86 - 91, The ordered list currently uses
three repeated "1." entries and triggers MD029; update the list so the prefixes
are sequential (e.g., "1. `write_comment_body`...", "2. `write_comment`...", "3.
`write_thread`...") so markdownlint passes; edit the block containing the three
functions (`write_comment_body`, `write_comment`, `write_thread`) to use
sequential numbering and verify with the repo's markdownlint rules.
src/main_tests.rs (1)

61-75: 🛠️ Refactor suggestion | 🟠 Major

Wrap environment restoration in a guard to ensure panic-safety.

The closure-based helper does not guarantee cleanup if f(err) panics—lines 71–74 will be skipped. An RAII guard with Drop ensures the original environment state is always restored.

♻️ Proposed refactor using guard pattern
+struct EnvGuard {
+    key: &'static str,
+    original: Option<String>,
+}
+
+impl Drop for EnvGuard {
+    fn drop(&mut self) {
+        match &self.original {
+            Some(v) => set_var(self.key, v),
+            None => remove_var(self.key),
+        }
+    }
+}
+
 fn with_invalid_http_timeout_error<F>(f: F)
 where
     F: FnOnce(Arc<ortho_config::OrthoError>),
 {
-    let old_timeout = environment::var("VK_HTTP_TIMEOUT").ok();
-    remove_var("VK_HTTP_TIMEOUT");
+    let _guard = EnvGuard {
+        key: "VK_HTTP_TIMEOUT",
+        original: environment::var("VK_HTTP_TIMEOUT").ok(),
+    };
+    remove_var("VK_HTTP_TIMEOUT");
     set_var("VK_HTTP_TIMEOUT", "not-a-number");
     let err = GlobalArgs::load_from_iter(std::iter::once(OsString::from("vk")))
         .expect_err("invalid VK_HTTP_TIMEOUT should fail");
     f(err);
-    match old_timeout {
-        Some(value) => set_var("VK_HTTP_TIMEOUT", value),
-        None => remove_var("VK_HTTP_TIMEOUT"),
-    }
 }

As per coding guidelines, "Use rstest fixtures for shared setup and to avoid repetition between tests" and "env mutations in tests MUST be wrapped in shared guards".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main_tests.rs` around lines 61 - 75, The helper
with_invalid_http_timeout_error currently mutates VK_HTTP_TIMEOUT and restores
it after calling f(err), but if f(err) panics the restoration is skipped;
replace the manual restore with an RAII guard struct (e.g., EnvVarGuard) created
before calling GlobalArgs::load_from_iter that captures old_timeout and
implements Drop to restore or remove VK_HTTP_TIMEOUT, then remove the explicit
post-call set_var/remove_var lines and invoke f(err) normally so cleanup is
guaranteed even on panic; reference the helper function name
with_invalid_http_timeout_error and the closure invocation f(err) when applying
this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@docs/vk-design.md`:
- Around line 70-78: The footnote definition is escaped as "\[^github-link\]:",
preventing the footnote from resolving; update the footnote label by removing
the backslashes so it reads "[^github-link]: GitHub Docs. \"Linking to a pull
request comment.\"" (leave the URL and surrounding mdformat directives intact)
so the inline reference [^github-link] resolves correctly.
- Around line 86-91: The ordered list currently uses three repeated "1." entries
and triggers MD029; update the list so the prefixes are sequential (e.g., "1.
`write_comment_body`...", "2. `write_comment`...", "3. `write_thread`...") so
markdownlint passes; edit the block containing the three functions
(`write_comment_body`, `write_comment`, `write_thread`) to use sequential
numbering and verify with the repo's markdownlint rules.

In `@src/main_tests.rs`:
- Around line 61-75: The helper with_invalid_http_timeout_error currently
mutates VK_HTTP_TIMEOUT and restores it after calling f(err), but if f(err)
panics the restoration is skipped; replace the manual restore with an RAII guard
struct (e.g., EnvVarGuard) created before calling GlobalArgs::load_from_iter
that captures old_timeout and implements Drop to restore or remove
VK_HTTP_TIMEOUT, then remove the explicit post-call set_var/remove_var lines and
invoke f(err) normally so cleanup is guaranteed even on panic; reference the
helper function name with_invalid_http_timeout_error and the closure invocation
f(err) when applying this change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 888f1907-288c-4ef6-9f3a-75cdf025ad67

📥 Commits

Reviewing files that changed from the base of the PR and between 71a76e5 and be359a5.

📒 Files selected for processing (2)
  • docs/vk-design.md
  • src/main_tests.rs

Refactored existing tests that verify invalid VK_HTTP_TIMEOUT handling by
introducing rstest fixtures `invalid_http_timeout` and
`invalid_http_timeout_error` for environment setup and error capturing.
This improves test isolation and readability by cleaning up manual setup
and teardown, and by utilizing rstest attributes to parametrize tests.
Also added EnvGuard struct to manage environment variable restoration
safely across test runs.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main_tests.rs`:
- Around line 42-52: Collapse the two tests cli_loads_repo_from_flag and
cli_loads_github_token_from_flag into a single parameterised rstest: create one
#[rstest(...)] test function (e.g., cli_loads_global_flags) that iterates over
tuples of (args, expected_field) for the two cases, call
Cli::try_parse_from(["vk", flag, value, "pr", "1"]) inside the test, then assert
the appropriate field on cli.global (use cli.global.repo.as_deref() and
cli.global.github_token.as_deref() depending on the parameter) to check the
expected value; keep the existing parse invocation (Cli::try_parse_from) and
assertions but drive them from the rstest parameters.
- Around line 56-78: Add a new function environment::var_os that mirrors the
existing environment::var but returns Option<OsString> (handling non-UTF8
values), then update EnvGuard and invalid_http_timeout to call
environment::var_os and store original as Option<OsString> (change
EnvGuard::original type accordingly); finally restore the original value in Drop
using environment::set_var_os when Some(OsString) or environment::remove_var
when None (add set_var_os if not present) so non-UTF8 env values are preserved.
🪄 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

Run ID: 8695dad9-4b47-4110-8876-9153f4006434

📥 Commits

Reviewing files that changed from the base of the PR and between be359a5 and 3aa7f51.

📒 Files selected for processing (1)
  • src/main_tests.rs

Comment thread src/main_tests.rs Outdated
…ocking

Introduce `set_var_os` and `var_os` functions in the environment module to allow setting and reading environment variables using `OsStr`/`OsString` types while holding the global mutex lock. This improves safe and consistent environment variable access when dealing with non-UTF8 values. Also update tests to use these new functions for safer env var management.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/environment.rs`:
- Around line 29-35: The two setter wrappers are duplicates: remove the
redundant set_var_os function and keep only set_var (both have signatures K:
AsRef<OsStr>, V: AsRef<OsStr>> and call the same locked unsafe env::set_var).
Before deleting, verify that signatures match and that all remaining set_var_os
calls are test-only; if any tests rely on the OS-specific name, change the
test-only re-export to alias set_var as set_var_os in the test utilities (e.g.,
update the test helper export in test_utils to pub use
crate::environment::set_var as set_var_os) and then delete the set_var_os
implementation from src/environment.rs.

In `@src/main_tests.rs`:
- Around line 201-213: Collapse the two tests into a single parameterised
rstest: replace the two #[test] functions resolve_subcommand_parses and
resolve_subcommand_parses_message with one #[rstest] fn
resolve_subcommand_parses that takes #[case] argv: &[&str] and #[case]
expected_message: Option<&str>, call parse_resolve_args(argv), assert
args.reference == "83#discussion_r1", and assert args.message.as_deref() ==
expected_message; add two cases (one with argv
["vk","resolve","83#discussion_r1"] and expected_message None, and one with argv
["vk","resolve","83#discussion_r1","-m","done"] and expected_message
Some("done")) so duplication around parse_resolve_args is removed.
- Around line 63-85: The current invalid_http_timeout fixture mutates the
environment in two separate critical sections causing race conditions; move the
fixture into test_utils and implement it using vk::environment::with_lock so
snapshotting the original value and setting "VK_HTTP_TIMEOUT" to "not-a-number"
happen inside the same locked section, and ensure EnvGuard's Drop also restores
or removes the variable inside with_lock to avoid restoring a stale value;
update the invalid_http_timeout fixture to construct and return this shared,
lock-wrapped EnvGuard from test_utils so other tests reuse the same guard/lock.
🪄 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

Run ID: 7fd880c1-e339-4250-9bd0-d531695473b7

📥 Commits

Reviewing files that changed from the base of the PR and between 3aa7f51 and fe09e1b.

📒 Files selected for processing (3)
  • src/environment.rs
  • src/main.rs
  • src/main_tests.rs

Comment thread src/environment.rs Outdated
Comment thread src/main_tests.rs Outdated
Comment thread src/main_tests.rs Outdated
…nd guards

- Removed `set_var_os` from environment module and tests.
- Replaced individual set/remove functions with `EnvGuard` struct that restores env vars on drop.
- Added `invalid_http_timeout_guard` to safely manage VK_HTTP_TIMEOUT test setup.
- Updated tests to use `EnvGuard` and `rstest` parametrized tests for clarity and safety.
- Centralized environment variable locking for thread-safe test setups.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@src/test_utils.rs`:
- Around line 225-243: In the Drop impl for EnvSandbox, swap the order so
environment::with_lock(...) runs first to restore original_env, then restore the
working directory; also make the env::set_current_dir call non-panicking (don’t
use expect) — handle or ignore the Result (e.g., match or log the Err) so a
failure to change dir won’t abort before env vars are restored. Keep changes
inside impl Drop for EnvSandbox and update references to env::set_current_dir
and environment::with_lock accordingly.
🪄 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

Run ID: cd92eb7b-a4aa-4dc4-b5d4-021523221c20

📥 Commits

Reviewing files that changed from the base of the PR and between fe09e1b and 20cbe5c.

📒 Files selected for processing (4)
  • src/environment.rs
  • src/main.rs
  • src/main_tests.rs
  • src/test_utils.rs

Comment thread src/test_utils.rs
…ir errors

In the Drop implementation for EnvSandbox, changed env::set_current_dir from expect() to ignoring its Result. This prevents potential panics during test cleanup and ensures environment restoration is attempted without aborting on failure.

Also, fixed numbering in the migration guide documentation for clarity.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos leynos changed the title Upgrade ortho-config to v0.8.0; add global-args loader and tests Upgrade ortho-config to v0.8.0; add global-args loader, tests, and docs Mar 12, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
docs/ortho-config-v0-6-0-migration-guide.md (2)

51-60: ⚠️ Potential issue | 🟡 Minor

Renumber this list.

Use 2. on Line 55 and 3. on Line 59. The repeated 1. prefixes still trigger MD029.

As per coding guidelines, **/*.md: Validate Markdown with make markdownlint.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/ortho-config-v0-6-0-migration-guide.md` around lines 51 - 60, The
ordered list uses repeated "1." markers causing MD029; update the three list
entries so they read "1. Change every `ortho_config` dependency...", "2. Retain
any optional features (such as `json5`, `yaml`, or `toml`) on the main
`ortho_config` dependency...", and "3. Rebuild the project to confirm the
upgraded macro compiles cleanly..." so the second and third items use "2." and
"3." respectively to fix the markdown lint failure.

225-269: ⚠️ Potential issue | 🟡 Minor

Remove the escapes from these footnote definitions.

Drop the leading backslash from each [^...]: line in this block. The current form renders the notes as plain text instead of GitHub-flavoured footnotes.

As per coding guidelines, **/*.md: Use GitHub-flavoured Markdown footnotes ([^1]) for references.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/ortho-config-v0-6-0-migration-guide.md` around lines 225 - 269, The
footnote definitions are escaped (leading backslashes) so GitHub Markdown
renders them as plain text; remove the leading backslash from each footnote
label (e.g. change \[^forwarded-features\], \[^hello-world-cargo\],
\[^reexports\], \[^hello-world-figment\], \[^discovery-attr\],
\[^hello-world-discovery\], \[^discovery-errors\],
\[^hello-world-discover-config\], \[^saphyr\], \[^hello-world-yaml\],
\[^changelog\] to [^forwarded-features], [^hello-world-cargo], [^reexports],
[^hello-world-figment], [^discovery-attr], [^hello-world-discovery],
[^discovery-errors], [^hello-world-discover-config], [^saphyr],
[^hello-world-yaml], [^changelog]) so they become GitHub-flavoured footnotes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test_utils.rs`:
- Around line 98-132: EnvGuard currently releases the process-wide lock
immediately after setting VK_HTTP_TIMEOUT, allowing races; modify EnvGuard to
hold the env_sandbox_lock() MutexGuard for the guard's lifetime by adding a
field (e.g. guard: Option<MutexGuard<()>>) to EnvGuard, acquire
env_sandbox_lock() inside invalid_http_timeout_guard() before reading and
setting the variable and store the resulting MutexGuard in the EnvGuard struct
(keep original as before), and update Drop for EnvGuard to restore the
environment variable without reacquiring the lock (the held MutexGuard ensures
serialization) so the lock is only released when EnvGuard is dropped; reference
EnvGuard, invalid_http_timeout_guard(), and env_sandbox_lock() when making these
changes.
- Around line 192-208: The setup currently clears environment variables inside
environment::with_lock and then calls env::set_current_dir which may panic after
the env is mutated with no EnvSandbox to restore them; change the sequence and
error handling in the sandbox setup so the working directory is changed before
mutating environment OR wrap the env mutations in a fallible sequence that rolls
back on error and returns a Result instead of panicking. Concretely, ensure
env::set_current_dir(&sandbox_path) (or construction of the EnvSandbox that will
restore state) runs prior to the unsafe env::remove_var / env::set_var calls
inside environment::with_lock, or capture and restore previous env values on any
error path, and propagate errors via Result rather than calling expect/panic
(refer to env::set_current_dir, environment::with_lock and the
EnvSandbox/restore logic to locate where to adjust).

---

Duplicate comments:
In `@docs/ortho-config-v0-6-0-migration-guide.md`:
- Around line 51-60: The ordered list uses repeated "1." markers causing MD029;
update the three list entries so they read "1. Change every `ortho_config`
dependency...", "2. Retain any optional features (such as `json5`, `yaml`, or
`toml`) on the main `ortho_config` dependency...", and "3. Rebuild the project
to confirm the upgraded macro compiles cleanly..." so the second and third items
use "2." and "3." respectively to fix the markdown lint failure.
- Around line 225-269: The footnote definitions are escaped (leading
backslashes) so GitHub Markdown renders them as plain text; remove the leading
backslash from each footnote label (e.g. change \[^forwarded-features\],
\[^hello-world-cargo\], \[^reexports\], \[^hello-world-figment\],
\[^discovery-attr\], \[^hello-world-discovery\], \[^discovery-errors\],
\[^hello-world-discover-config\], \[^saphyr\], \[^hello-world-yaml\],
\[^changelog\] to [^forwarded-features], [^hello-world-cargo], [^reexports],
[^hello-world-figment], [^discovery-attr], [^hello-world-discovery],
[^discovery-errors], [^hello-world-discover-config], [^saphyr],
[^hello-world-yaml], [^changelog]) so they become GitHub-flavoured footnotes.
🪄 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

Run ID: ebeab639-3d30-49d1-806e-c0f52d6fda62

📥 Commits

Reviewing files that changed from the base of the PR and between 20cbe5c and 796f0a9.

📒 Files selected for processing (2)
  • docs/ortho-config-v0-6-0-migration-guide.md
  • src/test_utils.rs

Comment thread src/test_utils.rs
Comment thread src/test_utils.rs Outdated
- Added a MutexGuard field to EnvGuard to hold the env_sandbox_lock for the lifetime.
- Removed environment::with_lock calls, relying on the held MutexGuard instead.
- Ensures process-wide environment variable mutation is properly synchronized.
- Moved `set_current_dir` call in EnvSandbox::new for clarity.

This simplifies synchronization by tying env variable access to the MutexGuard's lifetime rather than explicit with_lock closures.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/test_utils.rs (1)

179-184: ⚠️ Potential issue | 🟠 Major

Propagate sandbox construction errors instead of panicking.

Replace .expect(...) at Line 182, Line 184, and Line 192 with fallible propagation from EnvSandbox::new (for example, return std::io::Result<Self>). Keep teardown deterministic without panic-driven control flow.

Proposed fix
 impl EnvSandbox {
     /// Create a new isolated environment and working-directory sandbox.
     #[must_use]
-    pub fn new() -> Self {
+    pub fn new() -> std::io::Result<Self> {
         let guard = env_sandbox_lock();
-        let sandbox_dir = tempfile::tempdir().expect("create environment sandbox");
+        let sandbox_dir = tempfile::tempdir()?;
         let sandbox_path = sandbox_dir.path().to_path_buf();
-        let current_dir = environment::with_lock(env::current_dir).expect("capture current dir");
+        let current_dir = environment::with_lock(env::current_dir)?;
@@
-        env::set_current_dir(&sandbox_path).expect("switch to environment sandbox");
+        env::set_current_dir(&sandbox_path)?;
@@
-        Self {
+        Ok(Self {
             current_dir,
             original_env,
             sandbox_dir,
             _guard: guard,
-        }
+        })
     }
 }
#!/bin/bash
# Verify panic-based error handling in non-test Rust modules.
rg -n -C1 '\.expect\(' src/test_utils.rs
rg -n -C1 'pub fn new\(\) -> Self' src/test_utils.rs

As per coding guidelines, **/*.rs: .expect() and .unwrap() are forbidden outside of tests. Errors must be propagated.

Also applies to: 192-192

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test_utils.rs` around lines 179 - 184, Change EnvSandbox::new to return a
fallible result (e.g., std::io::Result<Self>) and propagate errors instead of
calling expect: replace the calls to tempfile::tempdir(),
environment::with_lock(env::current_dir), and env::set_current_dir with
propagated results using ? inside EnvSandbox::new; keep using env_sandbox_lock()
and the same fields (current_dir, original_env, sandbox_dir, _guard) but return
Ok(Self { ... }) on success so teardown remains deterministic without
panic-driven control flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test_utils.rs`:
- Around line 105-117: EnvGuard::drop currently performs unsafe
env::set_var/remove_var without synchronising with the shared environment lock;
change it to wrap the match that uses self.original.take() inside
environment::with_lock(...) so the unsafe env mutations are serialized (use
environment::with_lock to call env::set_var or env::remove_var), and similarly
modify invalid_http_timeout_guard() to perform reading and setting of
VK_HTTP_TIMEOUT inside environment::with_lock (returning the original value from
the closure) instead of calling env::var_os and unsafe env::set_var outside the
lock; keep env_sandbox_lock usage for the guard field but ensure all unsafe
env::set_var/remove_var calls run inside environment::with_lock to guarantee
process-wide serialization.

---

Duplicate comments:
In `@src/test_utils.rs`:
- Around line 179-184: Change EnvSandbox::new to return a fallible result (e.g.,
std::io::Result<Self>) and propagate errors instead of calling expect: replace
the calls to tempfile::tempdir(), environment::with_lock(env::current_dir), and
env::set_current_dir with propagated results using ? inside EnvSandbox::new;
keep using env_sandbox_lock() and the same fields (current_dir, original_env,
sandbox_dir, _guard) but return Ok(Self { ... }) on success so teardown remains
deterministic without panic-driven control flow.
🪄 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

Run ID: 4291a297-c316-465e-919f-1b544faf2b52

📥 Commits

Reviewing files that changed from the base of the PR and between 796f0a9 and 323ad8d.

📒 Files selected for processing (1)
  • src/test_utils.rs

The EnvSandbox::new constructor now returns Result<Self, std::io::Error> instead of unwrapping internally. Corresponding changes update usages to handle errors explicitly, improving error handling and robustness in tests that create environment sandboxes. Minor related cleanups include wrapping env var changes in locks for safety.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/config_loader.rs`:
- Around line 107-127: Extract the duplicated sandbox and loader setup in the
tests into a shared helper (e.g., a new fn like
setup_global_args_without_cli_overrides(iter: impl IntoIterator<Item=OsString>)
-> (EnvSandbox, GlobalArgs)) that creates EnvSandbox::new(), writes any fixture
files if needed, and calls load_global_args_without_cli_overrides_from_iter;
update both test functions
load_global_args_without_cli_overrides_defaults_cleanly and
load_global_args_without_cli_overrides_honours_config_path_override to call this
helper and keep only their specific assertions (assert! checks and any
config_path-specific writes) so setup is centralized while assertions remain
per-test.

In `@src/test_utils.rs`:
- Around line 105-117: Extract a private helper (e.g., restore_env_key) that
takes (key: &str, original: Option<String>) and contains the match that calls
unsafe { env::set_var(key, value) } for Some and unsafe { env::remove_var(key) }
for None inside environment::with_lock closure; then replace the duplicate match
blocks in EnvGuard::drop and EnvSandbox::drop by calling this helper with
self.key and self.original.take() (or the equivalent field) so both drops reuse
the same restoration logic and remove duplication.
🪄 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

Run ID: 2e029e15-558b-4642-865f-9a394e952964

📥 Commits

Reviewing files that changed from the base of the PR and between 323ad8d and f7874d3.

📒 Files selected for processing (2)
  • src/config_loader.rs
  • src/test_utils.rs

Comment thread src/config_loader.rs Outdated
Comment thread src/test_utils.rs
Refactored test utilities by introducing a helper function to set up global args without CLI overrides, improving test clarity and reuse. Centralized environment variable restoration logic in EnvSandbox and EnvGuard drops with a dedicated restore_env_key function to reduce code duplication and improve safety in environment handling during tests.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos leynos changed the title Upgrade ortho-config to v0.8.0; add global-args loader, tests, and docs Upgrade ortho-config to v0.8.0; add global-args loader and tests Mar 13, 2026
@leynos leynos merged commit 0e345ed into main Mar 13, 2026
5 checks passed
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.

1 participant