Skip to content

Surface config flags in clap help output (including locale)#103

Open
leynos wants to merge 24 commits intomainfrom
surface-config-flags-in-help-taop69
Open

Surface config flags in clap help output (including locale)#103
leynos wants to merge 24 commits intomainfrom
surface-config-flags-in-help-taop69

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Apr 10, 2026

Summary

  • Implements and documents surface of Weaver's runtime configuration flags in clap-generated help output, aligning with roadmap item 3.2.1. The PR includes an ExecPlan (docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md) and the code/docs to surface six flags in both weaver --help and weaver daemon start --help without altering runtime parsing semantics.
  • Adds a shared help-command approach and supporting runtime wiring to keep help truthful while preserving the existing precedence contract (defaults < files < environment < CLI).
  • Introduces a Runtime-to-Help bridge: an augmented clap Command used for help/manpage generation, while the runtime CLI remains strict about flag ordering.

Changes

  • New file: docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md (new)
    • Contains purpose, constraints, tolerances, risks, progress, decisions, and validation plan for surfacing six config flags in help output.
    • Documents the current six flags to surface: --config-path, --daemon-socket, --log-filter, --log-format, --capability-overrides, and --locale.
  • New module: crates/weaver-cli/src/help.rs
    • Shared clap help rendering for runtime help output and manpage generation.
    • Augments the existing Cli command with the six config flags so help/manpages reflect the same surface as intended for runtime configuration.
  • New module: crates/weaver-cli/src/preflight.rs
    • Pre-clap guidance paths that should exit before configuration loading.
  • New tests: crates/weaver-cli/src/tests/unit/help_output.rs
    • Unit tests asserting that help output for top-level and daemon-start help includes all six flags and does not trigger daemon startup.
  • Build/script adjustments: crates/weaver-cli/build.rs
    • Now uses the augmented help command (help::command) for manpage generation, ensuring consistency between runtime help and manpage output.
  • CLI/runtime wiring: crates/weaver-cli/src/lib.rs
    • Introduces mod help; adds locale into the CLI-visible list of flags used for help rendering; exposes CONFIG_CLI_FLAGS updated to include --locale.
    • Enhanced run path to render help via the augmented command when DisplayHelp is requested, ensuring help output stays truthful without starting the daemon.
  • Runtime config contract: crates/weaver-config/src/lib.rs
    • Adds new Locale type exposure (via locale module) and a default locale function.
    • Adds a locale field to Config with CLI-facing metadata (long: locale, value_name: LOCALE).
  • Locale type: crates/weaver-config/src/locale.rs (new)
    • Validated locale wrapper around LanguageIdentifier with Display/Parse/Serialize/Deserialize support.
    • Provides en_US default and basic parsing/validation against BCP 47 identifiers.
  • Tests and features: various tests updated or added to cover help rendering and locale precedence.
    • Updated unit/integration tests to reflect presence of --locale in help surfaces.
    • Updated feature tests to ensure top-level and daemon-start help surfaces include the new flags.
  • Documentation and roadmap updates:
    • docs/roadmap.md marks the six flags as visible in help for both top-level and daemon-start commands.
    • docs/users-guide.md updated to mention the new flag and its visibility in help.
    • docs/weaver-design.md updated to reflect the planned help-rendering approach and the placement of locale within the shared config contract.
    • docs/execplans updated by adding the new ExecPlan artifact that explains the approach and plan in detail.

Rationale

  • Binds to roadmap 3.2.1 by making config flags visible in clap help, improving operator discoverability while preserving the existing precedence contract (defaults < files < environment < CLI).
  • Proposes a shared help-command approach to avoid drift with runtime parsing and to keep manpage generation in sync with help output.
  • Keeps weaver-config as the authoritative source of the config contract while enabling help-rendering metadata in the CLI.

Plan of work (Stage-based)

  • Stage A: Lock expected behaviour with failing tests
    • Add red tests for help surfaces asserting that both weaver --help and weaver daemon start --help list all six flags and that help does not trigger daemon startup.
  • Stage B: Add locale to the shared configuration contract (initial planning scope)
    • Extend Config to include locale as a real config field (subject to later bootstrap-localizer work).
  • Stage C: Centralize config-help metadata
    • Extract six-flag catalogue into a shared module and reuse it for both runtime parsing and help rendering.
  • Stage D: Reuse help builder in build script
    • Ensure the manpage is generated from the same augmented help output used at runtime.
  • Stage E: Document the shipped contract
    • Update weaver-design.md and users-guide.md to reflect the shipped behavior and the configuration contract.

Validation plan

  • Focused checks to validate the observable help output and ordering rules before runtime changes:
    • Verify that weaver --help and weaver daemon start --help show all six flags in the Options section.
    • Verify that none of these help surfaces start the daemon.
    • Ensure the help rendering remains truthful while preserving the existing runtime ordering rule.

Risks & constraints

  • Surface-only changes to help rendering must not loosen runtime flag ordering or acceptance.
  • Introducing locale into the shared contract may require coordination with roadmap 3.3.1 for bootstrap-localizer work.
  • Keep source files under maintainable size by extracting logic into shared helpers/modules.

Documentation impact

  • This PR is a planning artifact. Documentation updates (docs/weaver-design.md, docs/users-guide.md) are planned for subsequent stages once implementation details are stabilized.

How to review

  • Review the ExecPlan content for clarity, completeness, and alignment with roadmap 3.2.1.
  • Confirm the six flags are correctly identified and that the proposed stages cover testing, runtime semantics, and documentation alignment.
  • Provide feedback on any missing constraints or risks that should be captured in the plan.

◳ Generated by DevBoxer


ℹ️ Tag @devboxerhub to ask questions and address PR feedback

📎 Task: https://www.devboxer.com/task/d72d1d9a-4972-4a9d-92c6-c3f8954fce45

Summary by Sourcery

Surface shared runtime configuration flags in CLI help and manpage output while adding a validated locale setting to the configuration contract and documenting the updated behaviour.

New Features:

  • Expose the six shared configuration flags, including locale, in both top-level and daemon start clap help surfaces without changing runtime flag precedence semantics.
  • Introduce a Locale configuration field backed by a validated BCP 47 identifier with an en-US default in the shared configuration contract.
  • Provide a shared help command builder used by both runtime help handling and build-time manpage generation to keep operator surfaces consistent.

Enhancements:

  • Refactor CLI preflight guidance logic into a dedicated module and extend config flag metadata (value names) for clearer help output.
  • Extend configuration precedence coverage and CLI behaviour tests, including BDD scenarios, to cover the new locale field and help output expectations.

Documentation:

  • Add an execution plan document for surfacing configuration flags in help output and update design, user guide, and roadmap documentation to reflect the new help surfaces and locale contract.

Tests:

  • Add unit, integration, and behavioural tests ensuring help surfaces list all six configuration flags, avoid daemon startup, and honour locale precedence over file and environment sources.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 10, 2026

This PR implements ExecPlan 3-2-1 (docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md) to surface six Weaver runtime configuration flags in clap-generated help and manpages — --config-path, --daemon-socket, --log-filter, --log-format, --capability-overrides and --locale — for both weaver --help and weaver daemon start --help, while preserving runtime parsing semantics and precedence (defaults < files < environment < CLI).

Core changes

  • ExecPlan: new ExecPlan document (docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md) describing constraints, acceptance criteria, implementation plan, verification steps and staged rollout; linked to design and users-guide updates.
  • Locale newtype (crates/weaver-config):
    • New validated Locale type (BCP‑47/ICU-backed) with LocaleParseError, en-US default, Default/Display/FromStr and Serde (de)serialisation; unit and proptest coverage including JSON round-trips and Unicode-extension handling.
    • Integrated into Config as pub locale: Locale, accessor Config::locale(), and surfaced as --locale with CLI metadata.
  • Augmented help rendering (crates/weaver-cli):
    • help.rs: builds a cached, augmented clap::Command cloned from Cli::command(), adds global --config-path and dynamically generates config-related Args from Config::get_doc_metadata().fields (omitting validators). Generated metadata is promoted to 'static and cached via OnceLock to bound leaks. An after_help caveat about flag placement is appended and propagated to subcommands. Exposes write_help_for_args used for runtime --help and manpage generation.
    • build.rs: manpage generation now uses help::command() so generated manpages match augmented help.
    • lib.rs: parse_or_render_help delegates to help::write_help_for_args; added SHARED_CONFIG_HELP_FLAGS (includes --locale) to centralise expected help placeholders; runner flow refactored so preflight runs before config loading and actual execution only happens on a successful parse.
    • preflight.rs: preflight boundary that emits bare-invocation guidance and domain-specific guidance before config loading; maps writer errors to dedicated AppError variants and returns appropriate early-exit results.
    • runner_glue.rs: runtime glue for building CommandRequest and executing daemon-backed commands (execute_daemon_command, build_request), including stdin handling for apply-patch, auto-start and retry semantics; errors funnel to user-facing guidance and ExitCode conversion.
  • Errors: AppError variants added for help/guidance emission failures (e.g. EmitHelp, EmitGuidance, EmitBareHelp).
  • Tests:
    • Unit tests: help_output tests asserting long-help is augmented with shared flags; insta snapshot tests for top-level and daemon-start long help; preflight tests including writer-failure paths; proptest for config-flag splitting and Locale parsing/roundtrips; tests for writer BrokenPipe propagation.
    • Integration/behaviour tests: feature scenarios and main-entry integration tests asserting help outputs include shared flags and do not trigger daemon startup; BDD step added to assert help stdout contains shared flags.
    • weaver-config tests: configuration-precedence harness extended (EnvGuard via OnceLock to serialise env changes) and BDD steps for locale precedence.
    • Test hygiene: most tests use test-local expected flag constants (to avoid coupling to production constants); insta snapshots committed.
  • Documentation:
    • Developer guide (docs/developers-guide.md): documents augmented-command pattern, Box::leak rationale and bounded caching via OnceLock, preflight boundary and guidance emission, and Locale newtype semantics and deferred localisation bootstrap.
    • users-guide, weaver-design and roadmap updated to reflect --locale inclusion and the help-generation approach.
  • Dependencies:
    • Workspace additions: icu_locale_core, tracing and proptest; crates weaver-cli and weaver-config updated dev-deps (insta, proptest, serde_json where needed).

Implementation safety notes

  • Dynamically generated clap Arg strings are promoted to 'static using Box::leak; leaks are bounded by caching per-field with OnceLock and SAFETY comments document rationale. The augmented command is only used for help/manpage rendering and does not change runtime parsing semantics; help text explicitly warns that config flags only take effect when placed before the domain/subcommand.

Outstanding review/CI follow-ups

  • Add doc comments in runner_glue.rs for execute_daemon_command and build_request as requested by reviewers.
  • Replace any remaining tests that import production constants with test-local EXPECTED_SHARED_CONFIG_HELP_FLAGS where still present.
  • Ensure CI includes required dev-deps (insta, proptest) and that committed insta snapshots are validated in CI.
  • Add/complete a few missing unit/property tests called out in review (additional proptests, writer-failure paths, Locale property tests).
  • Add requested tracing instrumentation in runner_glue.rs per reviewer guidance.

Files of note

  • docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md (new ExecPlan)
  • crates/weaver-cli/src/help.rs, preflight.rs, runner_glue.rs, lib.rs, build.rs, tests (help-related)
  • crates/weaver-config/src/locale.rs and lib.rs (Locale newtype and Config integration)
  • docs/developers-guide.md, docs/users-guide.md, docs/weaver-design.md, docs/roadmap.md

This summary links the new ExecPlan to the implemented code and documentation changes and notes the remaining review hygiene items to close the PR.

Walkthrough

Summarise the added help rendering path that builds an augmented clap Command exposing shared config flags (including --locale), a preflight early‑exit guidance boundary, a runner glue layer for daemon RPC I/O, and tests/docs to ensure help/manpage outputs advertise config flags while runtime semantics require flags before the command domain.

Changes

Cohort / File(s) Summary
Locale Configuration
crates/weaver-config/src/locale.rs, crates/weaver-config/src/lib.rs
Add Locale newtype with BCP‑47 validation, serde support, Display/FromStr/Default; add Config.locale field, accessor and default; expose --locale CLI metadata.
Help Rendering System
crates/weaver-cli/src/help.rs, crates/weaver-cli/build.rs
Add help module that clones Cli::command(), augments it with --config-path and generated config args (promote dynamic strings to 'static), caches augmented Command, and provide write_help_for_args used by build/manpage generation.
Preflight and Error Handling
crates/weaver-cli/src/preflight.rs, crates/weaver-cli/src/errors.rs
Add preflight module to emit bare-invocation and domain guidance before config loading; add AppError::EmitHelp and map writer failures to explicit error variants.
CLI Integration & Runner Glue
crates/weaver-cli/src/lib.rs, crates/weaver-cli/src/runner_glue.rs, crates/weaver-cli/src/config.rs
Refactor help parsing into CliRunner::parse_or_render_help using help::write_help_for_args; add runner_glue with build_request and execute_daemon_command; remove ConfigArgumentSplit::has_config_flags; re-export preflight/runner symbols for tests.
Dependencies & Build
crates/weaver-cli/Cargo.toml, crates/weaver-config/Cargo.toml, Cargo.toml, Makefile
Add workspace deps (icu_locale_core, tracing, proptest, serde_json); add target/dev deps (ortho_config, weaver-config cli feature, insta); adjust Makefile to resolve mdformat-all robustly.
Tests: Unit & Integration
crates/weaver-cli/src/tests/unit/help_output.rs, crates/weaver-cli/src/tests/unit/bare_invocation.rs, crates/weaver-cli/src/tests/behaviour.rs, crates/weaver-cli/tests/main_entry.rs
Add unit tests verifying augmented long help includes shared config flags and avoids config loading; update bare‑invocation test to assert help emission; add insta snapshots and integration checks ensuring help invocations do not start the daemon.
BDD Feature Tests
crates/weaver-cli/tests/features/weaver_cli.feature, crates/weaver-config/tests/features/configuration_precedence.feature, crates/weaver-config/tests/configuration_precedence.rs
Add feature scenarios asserting top‑level and daemon start --help include shared flags and do not send daemon commands; extend configuration precedence tests with locale steps and serialise env mutations for test isolation.
Documentation & Roadmap
docs/execplans/..., docs/roadmap.md, docs/users-guide.md, docs/weaver-design.md, docs/developers-guide.md
Add exec plan and design notes for exposing shared config flags and two‑stage help; document --locale and precedence rules; update roadmap with 3.2.1 completion and manpage migration plan.
Misc / Shared Constants
crates/weaver-cli/src/lib.rs, crates/weaver-cli/src/tests/unit/help_output.rs
Introduce SHARED_CONFIG_HELP_FLAGS constant and use it across tests and help generation to assert presence of shared config flags in help output.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as CLI Parser
    participant Help as Help Module
    participant Preflight as Preflight Check
    participant Config as Config System
    participant Daemon as Daemon (socket)

    User->>CLI: Invoke weaver [argv]
    CLI->>Help: Inspect argv for --help/--version
    alt Help requested
        Help->>Help: Build augmented Command (Cli::command + config metadata + --config-path)
        Help->>User: write_help_for_args() -> stdout
        CLI-->>User: Exit SUCCESS
    else Normal execution
        CLI->>Preflight: handle_preflight(parsed_cli, stderr, localizer)
        alt Bare invocation or domain guidance needed
            Preflight->>User: Emit guidance -> stderr
            CLI-->>User: Exit preflight error
        else Proceed
            CLI->>Config: Load config (defaults < file < env < CLI)
            Config-->>CLI: Resolved config (includes locale)
            CLI->>Daemon: execute_daemon_command (connect or auto‑start)
            Daemon-->>CLI: Stream responses (JSONL)
            CLI-->>User: Command output / ExitCode
        end
    end
Loading

Poem

Help flags align and sing in rows,
Locale set where the contract grows,
Preflight guards the path ahead,
Daemon sleeps while help is read,
Tests and docs attest what the CLI shows. ✨

Prompt: Review the above summary, ensure tests and docs align with the implemented help/manpage generation approach, and run the integration help scenarios to confirm no daemon activity on help invocations.  

Caution

Pre-merge checks failed

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

  • Ignore

❌ Failed checks (1 error, 5 warnings, 2 inconclusive)

Check name Status Explanation Resolution
Testing (Overall) ❌ Error execute_daemon_command function lacks test coverage; snapshot tests vulnerable to vacuous passing; preflight error paths not fully verified. Add comprehensive unit tests for execute_daemon_command covering all paths. Verify snapshot tests with explicit oracle assertions. Ensure preflight.rs exercises all error paths.
User-Facing Documentation ⚠️ Warning Locale default documentation is missing from the Defaults section of docs/users-guide.md, creating inconsistency with other configuration options. Add bullet point to Defaults section documenting locale default as en-US to ensure all configuration options have consistent, discoverable default documentation.
Developer Documentation ⚠️ Warning ExecPlan document contains stale technical references that do not align with the actual shipped implementation. Replace three instances of unic_langid::LanguageIdentifier with ortho_config::LanguageIdentifier and change line 389 from 'likely en-US' to 'the default is en-US'.
Testing (Unit) ⚠️ Warning Unit test coverage for error paths is incomplete; execute_daemon_command and error-handling helpers lack direct unit tests for connection failures, message-reading errors, and error formatting. Add focused unit tests in runner_glue.rs verifying error paths directly: test write_error_and_fail with various error types, connection failures, response reading failures, and error-to-exit-code mapping with mocked daemon interactions.
Observability ⚠️ Warning PR introduces daemon spawning and retry logic without adequate instrumentation at critical operational decision points like connect_with_retry, try_auto_start_daemon, and stdin patch reading. Add tracing to connect_with_retry loop, include daemon_socket in execute_daemon_command span, instrument try_auto_start_daemon with debug events, and log patch stdin reading with relevant context.
Concurrency And State ⚠️ Warning OnceLock-cached leaked memory for clap arguments and environment variable mutations in tests lack explicit synchronisation boundaries and concurrent safety documentation. Document why OnceLock and Box::leak are correct, verify test synchronisation for environment mutations, add concurrent test for help rendering consistency, and publish EnvGuard implementation.
Title check ❓ Inconclusive The title accurately summarises the main change: surfacing configuration flags (including the newly added locale flag) in clap help output. It aligns with roadmap item 3.2.1 but omits the reference. Include the roadmap reference in the title, e.g., 'Surface config flags in clap help output—including locale (3.2.1)' to align with the requirement.
Module-Level Documentation ❓ Inconclusive Shell scripts provided assess documentation coverage in runner_glue.rs and related modules, but no execution results are available to verify actual pub items lack doc comments. Execute the provided shell scripts against the actual codebase to determine whether pub and pub(crate) functions in runner_glue.rs, help.rs, and locale.rs have complete documentation coverage.
✅ Passed checks (10 passed)
Check name Status Explanation
Description check ✅ Passed The PR description is comprehensive, relating directly to the changeset. It explains the objectives, documents the stages, rationale, risks, and validation plan, all aligned with implementing roadmap item 3.2.1.
Docstring Coverage ✅ Passed Docstring coverage is 95.28% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Testing (Property / Proof) ✅ Passed PR introduces substantive property-based tests for locale validation and configuration flag ordering invariants using custom generators and proptest.
Testing (Compile-Time / Ui) ✅ Passed PR appropriately uses snapshot testing for UI output, property-based testing for domain validation, and targeted unit tests for error paths.
Unit Architecture ✅ Passed Pull request maintains Unit Architecture principles: queries and commands properly separated, all operations have explicit dependencies injected as parameters, fallibility is visible in return types, process-level state is bounded and documented, and tests verify architectural boundaries correctly.
Domain Architecture ✅ Passed Pull request maintains strong domain-adapter separation with zero dependencies on CLI concerns and correct orchestration enforcing runtime parsing invariant.
Security And Privacy ✅ Passed The PR introduces no secrets, authentication bypasses, authorisation gaps, or injection risks. Configuration inputs are properly validated through ICU's locale parser and delegated to existing config loaders. Error messages safely escape user-supplied locale strings without exposing credentials or internal paths. Patch content is validated before transmission. Environment variables are read safely. Socket paths undergo proper validation and URL encoding. Test fixtures use clearly fake credentials and temporary directories. Serialisation uses safe JSONL format with validated deserialisation. No unsafe deserialisation, over-broad permissions, or sensitive data exposure in logs, errors, snapshots, or documentation.
Performance And Resource Use ✅ Passed Command cloning occurs only during help rendering (non-hot path), argument splitting is linear, retry loops are bounded by explicit timeouts, stdin reading for apply-patch is pre-existing, and Box::leak is process-lifetime bounded by OnceLock cache.
✨ 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 surface-config-flags-in-help-taop69

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

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 10, 2026

Reviewer's Guide

Surfaces six runtime configuration flags (including the new locale field) in clap-generated help and manpages via a shared augmented Command, while keeping the existing config precedence and flag-ordering semantics unchanged, and factors preflight/help logic into dedicated modules with corresponding tests and docs updates.

Sequence diagram for CLI help handling with shared augmented Command

sequenceDiagram
    actor Operator
    participant CliRunner as CliRunner
    participant ClapCli as Cli
    participant Help as help_command
    participant ConfigMeta as Config_doc_metadata
    participant Stdout as stdout

    Operator->>CliRunner: run_with_handler(argv)
    CliRunner->>CliRunner: split_config_arguments(argv)
    CliRunner->>CliRunner: prepare_cli_arguments(argv, split)
    CliRunner->>ClapCli: try_parse_from(cli_arguments)
    ClapCli-->>CliRunner: Error(DisplayHelp)
    CliRunner->>CliRunner: write_help_for_args(argv, stdout)
    CliRunner->>Help: command()
    Help->>ConfigMeta: Config::get_doc_metadata()
    ConfigMeta-->>Help: FieldMetadata for config fields
    Help-->>CliRunner: augmented Command
    CliRunner->>Help: try_get_matches_from(argv)
    Help-->>CliRunner: Error(DisplayHelp)
    CliRunner->>Stdout: write(help_text)
    Stdout-->>Operator: rendered help with 6 config flags
    CliRunner-->>Operator: exit(0) without starting daemon
Loading

Updated class diagram for Config, Locale, and help/preflight modules

classDiagram
    class Config {
        +SocketEndpoint daemon_socket
        +String log_filter
        +LogFormat log_format
        +Vec~CapabilityDirective~ capability_overrides
        +Locale locale
        +Config default()
        +capability_matrix() CapabilityMatrix
        +locale() &Locale
        -normalise_capability_overrides() void
    }

    class Locale {
        -LanguageIdentifier 0
        +Locale en_us()
        +Locale default()
        +to_string() String
        +from_str(value: &str) Result~Locale,LocaleParseError~
    }

    class LocaleParseError {
        -String input
        +to_string() String
    }

    class HelpModule {
        +command() Command
        -config_path_arg() Arg
        -config_field_arg(field: FieldMetadata) Option~Arg~
        -apply_arg_shape(arg: Arg, cli: CliMetadata) Arg
    }

    class PreflightModule {
        +handle_preflight(cli: Cli, split: ConfigArgumentSplit, stderr: ErrWriter, localizer: Localizer) Result~(),AppError~
        -emit_domain_guidance(cli: Cli, stderr: ErrWriter, localizer: Localizer, raw_domain: &str) Result~(),AppError~
        -preflight_result(written: bool) Result~(),AppError~
    }

    class AppError {
        <<enum>>
        PreflightGuidance
        BareInvocation
        EmitBareHelp(io::Error)
        EmitHelp(io::Error)
        CliUsage(clap::Error)
    }

    class CliRunner {
        +run_with_handler(args: &[OsString]) ExitCode
        -write_help_for_args(args: &[OsString], writer: &mut Write) io::Result~()~
    }

    Config --> Locale : has
    Locale --> LocaleParseError : error
    HelpModule --> Config : uses
    HelpModule --> CliRunner : used_by
    PreflightModule --> CliRunner : used_by
    PreflightModule --> AppError : returns
    CliRunner --> AppError : returns
Loading

File-Level Changes

Change Details Files
Add a shared help-command builder that augments clap help/manpages with the six configuration flags without changing runtime parsing semantics.
  • Introduce help::command() that wraps Cli::command() and appends config flags derived from weaver-config metadata plus a synthetic --config-path flag.
  • Build clap Args from OrthoConfigDocs FieldMetadata, including value names, multiplicity, and possible values, and mark them as global under an Options help heading.
  • Wire CliRunner to intercept clap DisplayHelp/DisplayVersion errors and render help via help::command(), writing directly to stdout and exiting successfully.
  • Update build.rs to use help::command() for clap_mangen manpage generation, ensuring the manpage matches runtime help output.
crates/weaver-cli/src/help.rs
crates/weaver-cli/src/lib.rs
crates/weaver-cli/build.rs
crates/weaver-cli/Cargo.toml
Model locale as a first-class, validated configuration field and expose it consistently across file, env, CLI, and help surfaces while preserving precedence tests.
  • Add a Locale newtype around LanguageIdentifier with Display/FromStr/Serde and a default en-US constructor, plus validation tests.
  • Extend Config with a locale field using ortho-config annotations to define default, cli_long="locale", and value_name="LOCALE", and provide a locale() accessor and default_locale helper.
  • Update CONFIG_CLI_FLAGS and config-argument splitting to recognise --locale as a config flag.
  • Extend configuration precedence tests and feature scenarios to cover locale across file, environment (WEAVER_LOCALE), and CLI, including a CLI-wins scenario and default assertions.
crates/weaver-config/src/locale.rs
crates/weaver-config/src/lib.rs
crates/weaver-config/tests/configuration_precedence.rs
crates/weaver-config/tests/features/configuration_precedence.feature
crates/weaver-cli/src/lib.rs
Refactor preflight guidance logic out of the CLI entrypoint into a dedicated module to keep lib.rs size/complexity under control.
  • Extract handle_preflight, emit_domain_guidance, and preflight_result into a new preflight module with the same behaviour and error mapping.
  • Update CliRunner to call preflight::handle_preflight instead of the inlined implementations.
crates/weaver-cli/src/preflight.rs
crates/weaver-cli/src/lib.rs
Add unit, integration, and BDD feature coverage asserting the presence of shared config flags in help output and the absence of daemon startup on help paths.
  • Add unit tests that run the CLI with a PanickingLoader and assert that both top-level and daemon start help list all six flags and do not attempt configuration loading.
  • Extend main_entry integration tests to assert presence of the six flags in weaver --help and daemon start --help and successful exit codes.
  • Extend weaver_cli.feature with scenarios ensuring top-level and daemon start help show the six flags and do not send daemon commands.
  • Wire the new unit test module into the existing weaver-cli test harness.
crates/weaver-cli/src/tests/unit/help_output.rs
crates/weaver-cli/tests/main_entry.rs
crates/weaver-cli/tests/features/weaver_cli.feature
crates/weaver-cli/src/tests/unit.rs
Document the execution plan, roadmap status, and user-facing configuration/help behaviour for the new shared configuration flags and locale.
  • Add an ExecPlan detailing purpose, constraints, risks, staged work plan, validation, and outcomes for roadmap item 3.2.1.
  • Update docs/users-guide.md to list --locale, describe its semantics and precedence, and note that both weaver --help and weaver daemon start --help surface the six shared config flags.
  • Update docs/weaver-design.md to describe the augmented-command approach to help rendering and how locale fits into the configuration contract and future localisation work.
  • Mark roadmap item 3.2.1 tasks as completed and add follow-on 3.2.6 notes about future cargo-orthohelp adoption for manpages.
docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md
docs/users-guide.md
docs/weaver-design.md
docs/roadmap.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

codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos leynos changed the title Plan: surface config flags in clap help output Surface config flags in clap help output Apr 11, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos leynos changed the title Surface config flags in clap help output Surface config flags in clap help output (including locale) Apr 11, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos leynos marked this pull request as ready for review April 13, 2026 08:51
@leynos leynos force-pushed the surface-config-flags-in-help-taop69 branch from 775be84 to e368e50 Compare April 13, 2026 08:51
codescene-delta-analysis[bot]

This comment was marked as outdated.

sourcery-ai[bot]

This comment was marked as resolved.

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: e368e50bd0

ℹ️ 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 crates/weaver-cli/src/help.rs Outdated
@coderabbitai coderabbitai Bot added the Roadmap label Apr 13, 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: 7

Caution

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

⚠️ Outside diff range comments (1)
crates/weaver-cli/src/lib.rs (1)

35-60: 🛠️ Refactor suggestion | 🟠 Major

Collapse the config-flag catalogue to one source of truth.

help::command() now discovers config flags from Config::get_doc_metadata().fields, but runtime splitting still depends on this hand-maintained slice. The next config field will show up in --help and remain inert at runtime until somebody edits CONFIG_CLI_FLAGS, which recreates the contract drift this PR is meant to remove. Source both paths from the same metadata, or centralize the catalogue in one shared helper.

Based on learnings, "Define the shared configuration schema for weaver-cli and weaverd in weaver-config, using ortho-config to merge config files, environment overrides, and CLI flags for daemon sockets, logging, and the capability matrix defaults."

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

In `@crates/weaver-cli/src/lib.rs` around lines 35 - 60, Replace the
hand-maintained CONFIG_CLI_FLAGS slice with a single source of truth derived
from the configuration metadata: remove or stop using the CONFIG_CLI_FLAGS
constant and instead obtain the CLI flag names from
Config::get_doc_metadata().fields (the same place help::command() reads from),
then pass that generated list into split_config_arguments/prepare_cli_arguments
where CONFIG_CLI_FLAGS was used; ensure the extraction maps metadata field names
to the exact flag strings (e.g. "--config-path", "--daemon-socket", etc.) and
preserve any ordering/escaping logic previously assumed by
split_config_arguments so runtime flag-splitting and help generation stay in
sync.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/weaver-cli/src/help.rs`:
- Around line 17-24: The generated help currently exposes config flags as global
clap options but doesn't state the parsing order caveat; update the help text
for the Command built in command() (the code that iterates
Config::get_doc_metadata().fields and calls config_field_arg()) to append a
clear note in long_about or after_help stating that config flags must appear
before the domain or structured subcommand (e.g., "Config flags are only honored
when placed before the domain/structured subcommand, e.g., `weaver daemon start
--flag` must place --flag before the subcommand"); apply the same addition to
the other help augmentation site referenced around lines 48-51 so both places
document the ordering rule.

In `@crates/weaver-cli/src/lib.rs`:
- Around line 251-268: The file exceeds the 400-line limit; extract the
help/runner plumbing by moving the write_help_for_args function and any related
runner/help helpers into a new module (e.g., help.rs or runner_help.rs) and
re-export or call it from lib.rs; specifically, relocate the function
write_help_for_args and any closely related helper functions or types used by
the runner/help code into that module, update lib.rs to use mod help; use
pub(crate) or pub as needed and adjust imports (help::write_help_for_args or
re-export) so callers continue to compile, then run cargo check to verify no
unresolved imports remain.

In `@crates/weaver-cli/tests/main_entry.rs`:
- Around line 146-157: The test daemon_start_help_lists_all_config_flags must
also assert that invoking "weaver daemon start --help" does not proceed into the
daemon startup path; update the test function
daemon_start_help_lists_all_config_flags to add negative assertions that the
startup log/message ("Waiting for daemon start...") is not present on stdout or
stderr by appending .stdout(predicates::str::contains("Waiting for daemon
start...").not()) and .stderr(predicates::str::contains("Waiting for daemon
start...").not()) to the existing assert chain (use predicates::str::contains to
build the negative checks).

In `@crates/weaver-config/src/lib.rs`:
- Around line 101-108: Update the crate-level Rustdoc to reflect the new public
field by adding "locale" to the opening schema summary and ensure the module
begins with a module-level (`//!`) comment; specifically edit the top-of-file
crate docs in lib.rs to include "locale" alongside the existing configuration
concerns and add or update the leading //! comment block so it documents the
module's purpose and lists the fields (including the public pub locale: Locale
field and reference to default_locale()).

In `@crates/weaver-config/tests/configuration_precedence.rs`:
- Around line 136-139: The Harness::set_env call performs unguarded global env
mutation (uses unsafe std::env::set_var) and races under parallel tests; wrap
all test environment mutations behind a shared synchronization primitive: add a
static Mutex<()> (in the shared test_utils/test_helpers crate) and modify
Harness::set_env to acquire that mutex before calling std::env::set_var and to
return a guard-style RAII object that holds the mutex and restores the previous
value in its Drop (or alternatively switch Harness to use dependency
injection/mocking via the mockable crate); ensure all tests call the new guarded
API so env sets are serialized and restored safely.

In `@docs/roadmap.md`:
- Around line 294-299: Mark the roadmap parent task for item "3.2.1" as complete
by updating its headline checkbox to checked (e.g., change the parent checklist
item for 3.2.1 to [x]) so the document no longer shows the feature as open;
ensure the headline references the same sub-items and the six flags
(--config-path, --daemon-socket, --log-filter, --log-format,
--capability-overrides, --locale) and acceptance criteria remain unchanged.

In `@docs/weaver-design.md`:
- Around line 697-699: Change the British spelling "localisation" to the Oxford
-ize form "localization" in the phrase under Roadmap item `3.2.1` (replace the
token "localisation" where it appears in the sentence referencing clap
localisation/Command usage) so the documentation matches the repository's
en-GB-oxendict (-ize) spelling policy.

---

Outside diff comments:
In `@crates/weaver-cli/src/lib.rs`:
- Around line 35-60: Replace the hand-maintained CONFIG_CLI_FLAGS slice with a
single source of truth derived from the configuration metadata: remove or stop
using the CONFIG_CLI_FLAGS constant and instead obtain the CLI flag names from
Config::get_doc_metadata().fields (the same place help::command() reads from),
then pass that generated list into split_config_arguments/prepare_cli_arguments
where CONFIG_CLI_FLAGS was used; ensure the extraction maps metadata field names
to the exact flag strings (e.g. "--config-path", "--daemon-socket", etc.) and
preserve any ordering/escaping logic previously assumed by
split_config_arguments so runtime flag-splitting and help generation stay in
sync.
🪄 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: 3f24dcff-e524-4859-b140-2de6468dbfae

📥 Commits

Reviewing files that changed from the base of the PR and between 13215a5 and e368e50.

📒 Files selected for processing (18)
  • crates/weaver-cli/Cargo.toml
  • crates/weaver-cli/build.rs
  • crates/weaver-cli/src/errors.rs
  • crates/weaver-cli/src/help.rs
  • crates/weaver-cli/src/lib.rs
  • crates/weaver-cli/src/preflight.rs
  • crates/weaver-cli/src/tests/unit.rs
  • crates/weaver-cli/src/tests/unit/help_output.rs
  • crates/weaver-cli/tests/features/weaver_cli.feature
  • crates/weaver-cli/tests/main_entry.rs
  • crates/weaver-config/src/lib.rs
  • crates/weaver-config/src/locale.rs
  • crates/weaver-config/tests/configuration_precedence.rs
  • crates/weaver-config/tests/features/configuration_precedence.feature
  • docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md
  • docs/roadmap.md
  • docs/users-guide.md
  • docs/weaver-design.md

Comment thread crates/weaver-cli/src/help.rs Outdated
Comment thread crates/weaver-cli/src/lib.rs Outdated
Comment thread crates/weaver-cli/tests/main_entry.rs Outdated
Comment thread crates/weaver-config/src/lib.rs
Comment thread crates/weaver-config/tests/configuration_precedence.rs
Comment thread docs/roadmap.md
Comment thread docs/weaver-design.md Outdated
@leynos

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

codescene-delta-analysis[bot]

This comment was marked as 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: 2

♻️ Duplicate comments (3)
docs/roadmap.md (1)

285-299: ⚠️ Potential issue | 🟡 Minor

Mark roadmap item 3.2.1 complete.

Update the parent checkbox as well. The sub-task and acceptance criteria underneath it are already marked done, so the headline item now reports shipped work as still open.

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

In `@docs/roadmap.md` around lines 285 - 299, The roadmap entry 3.2.1 still lists
the top-level checkbox as open despite its subitems being completed; edit the
"3.2.1. Surface configuration flags in clap help output." headline checkbox to
checked (mark the parent checkbox complete) so it matches the already-checked
subtask lines for `--config-path`, `--daemon-socket`, `--log-filter`,
`--log-format`, `--capability-overrides`, and `--locale` and leave the
acceptance criteria text unchanged.
crates/weaver-cli/src/preflight.rs (1)

109-185: 🧹 Nitpick | 🔵 Trivial

Collapse the repeated preflight cases into rstest tables.

Duplicate the setup once, then parameterize the scenario inputs and expected guidance. These tests repeat the same arrange/act/assert flow, and the unknown-domain and missing-operation cases differ only by the input tuple and assertion needle. Fold them into #[rstest] cases with a shared fixture for the localizer and buffers so later guidance paths stay aligned.

As per coding guidelines, "Use rstest fixtures for shared setup in Rust tests." and "Replace duplicated tests with #[rstest(...)] parameterised cases in Rust."

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

In `@crates/weaver-cli/src/preflight.rs` around lines 109 - 185, Collapse the six
near-duplicate tests into a single parameterized rstest: create a shared fixture
(using rstest) that sets up test_localizer() and a mutable stderr Vec<u8>, then
add a #[rstest] table with columns for domain (Option<&str>), operation
(Option<&str>), expected_result (Result variant or AppError discriminant), and
optional expected_stderr_substring; for each row call
handle_preflight(&cli(domain, operation), &split(...)) using the appropriate
split flag, assert matches!(result, expected_result) and, if
expected_stderr_substring is Some, convert stderr to String and assert it
contains the needle, otherwise assert stderr.is_empty(); reference the existing
helpers test_localizer, cli, split, and handle_preflight when implementing the
fixture and parameterized cases.
crates/weaver-cli/src/help.rs (1)

20-30: ⚠️ Potential issue | 🟠 Major

Surface the ordering caveat on every help screen that shows these flags.

Add the note in the augmented builder itself. help::command() now exposes the shared config flags on nested screens such as weaver daemon start --help, but that screen does not carry the top-level warning that the runtime only honours those flags before the domain or structured subcommand. Without that caveat, the help output advertises placements the runtime still ignores.

Based on learnings, "CLI flags must appear before the command domain or structured subcommand to take effect."

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

In `@crates/weaver-cli/src/help.rs` around lines 20 - 30, The help builder
returned by help::command() should append the ordering caveat to every generated
help screen: after constructing the Command from Cli::command() and adding
config_path_arg() and config_field_arg(...) entries, call the Command
help-extender (e.g., after_help or before_help) on the Command returned by
command() to append the text "CLI flags must appear before the command domain or
structured subcommand to take effect." so every nested help (like when using
Cli::command() for subcommands) shows this warning; update the function that
returns Command (help::command) to attach that message to the Command before
returning it.
🤖 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/3-2-1-surface-configuration-flags-in-clap-help-output.md`:
- Line 336: Change the British spelling "recognises" to the repository's Oxford
-ize form "recognizes" in the documentation instances that mention
split_config_arguments(...); update both occurrences (the one describing
`split_config_arguments(...)` recognising `--locale` and the other occurrence
noted) so the docs use "recognizes" consistently.
- Around line 264-268: Remove the duplicated fragment in the retrospective
bullet so it reads as one coherent sentence: delete the repeated
"crates/weaver-cli/src/help.rs" clause and ensure the sentence mentions only
once that `cargo orthohelp` will replace the `clap_mangen` infrastructure in CI,
keeping the runtime parser strict and referencing
`crates/weaver-cli/src/help.rs` and `crates/weaver-cli/build.rs` only once each
as needed.

---

Duplicate comments:
In `@crates/weaver-cli/src/help.rs`:
- Around line 20-30: The help builder returned by help::command() should append
the ordering caveat to every generated help screen: after constructing the
Command from Cli::command() and adding config_path_arg() and
config_field_arg(...) entries, call the Command help-extender (e.g., after_help
or before_help) on the Command returned by command() to append the text "CLI
flags must appear before the command domain or structured subcommand to take
effect." so every nested help (like when using Cli::command() for subcommands)
shows this warning; update the function that returns Command (help::command) to
attach that message to the Command before returning it.

In `@crates/weaver-cli/src/preflight.rs`:
- Around line 109-185: Collapse the six near-duplicate tests into a single
parameterized rstest: create a shared fixture (using rstest) that sets up
test_localizer() and a mutable stderr Vec<u8>, then add a #[rstest] table with
columns for domain (Option<&str>), operation (Option<&str>), expected_result
(Result variant or AppError discriminant), and optional
expected_stderr_substring; for each row call handle_preflight(&cli(domain,
operation), &split(...)) using the appropriate split flag, assert
matches!(result, expected_result) and, if expected_stderr_substring is Some,
convert stderr to String and assert it contains the needle, otherwise assert
stderr.is_empty(); reference the existing helpers test_localizer, cli, split,
and handle_preflight when implementing the fixture and parameterized cases.

In `@docs/roadmap.md`:
- Around line 285-299: The roadmap entry 3.2.1 still lists the top-level
checkbox as open despite its subitems being completed; edit the "3.2.1. Surface
configuration flags in clap help output." headline checkbox to checked (mark the
parent checkbox complete) so it matches the already-checked subtask lines for
`--config-path`, `--daemon-socket`, `--log-filter`, `--log-format`,
`--capability-overrides`, and `--locale` and leave the acceptance criteria text
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6c2aeff5-0d4f-4544-9bce-f44160f28254

📥 Commits

Reviewing files that changed from the base of the PR and between e368e50 and a6b72ad.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • crates/weaver-cli/src/tests/unit/snapshots/weaver_cli__tests__unit__help_output__daemon_start_augmented_help.snap is excluded by !**/*.snap
  • crates/weaver-cli/src/tests/unit/snapshots/weaver_cli__tests__unit__help_output__top_level_augmented_help.snap is excluded by !**/*.snap
📒 Files selected for processing (10)
  • crates/weaver-cli/Cargo.toml
  • crates/weaver-cli/src/help.rs
  • crates/weaver-cli/src/preflight.rs
  • crates/weaver-cli/src/tests/unit/help_output.rs
  • crates/weaver-config/Cargo.toml
  • crates/weaver-config/src/lib.rs
  • crates/weaver-config/src/locale.rs
  • docs/developers-guide.md
  • docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md
  • docs/roadmap.md

Comment thread docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md Outdated
Comment thread docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md Outdated
@lodyai lodyai Bot force-pushed the surface-config-flags-in-help-taop69 branch from a6b72ad to d0909bf Compare April 27, 2026 07:27
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as 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: 2

♻️ Duplicate comments (8)
crates/weaver-cli/tests/main_entry.rs (1)

146-157: ⚠️ Potential issue | 🟡 Minor

Assert daemon startup does not run on daemon start --help.

Add negative assertions for the startup message on both streams. Line 146 currently verifies flag visibility only, so a side-effect regression can still pass this test.

Patch
 #[test]
 fn daemon_start_help_lists_all_config_flags() {
     let mut command = cargo_bin_cmd!("weaver");
     command.args(["daemon", "start", "--help"]);
     command
         .assert()
         .success()
         .stdout(contains("--config-path <PATH>"))
         .stdout(contains("--daemon-socket <ENDPOINT>"))
         .stdout(contains("--log-filter <FILTER>"))
         .stdout(contains("--log-format <FORMAT>"))
         .stdout(contains("--capability-overrides <DIRECTIVE>"))
-        .stdout(contains("--locale <LOCALE>"));
+        .stdout(contains("--locale <LOCALE>"))
+        .stdout(contains("Waiting for daemon start...").not())
+        .stderr(contains("Waiting for daemon start...").not());
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/weaver-cli/tests/main_entry.rs` around lines 146 - 157, The test
daemon_start_help_lists_all_config_flags currently only asserts help flags and
misses verifying no daemon startup side effects; update the assertion chain on
the command created by cargo_bin_cmd!("weaver") in function
daemon_start_help_lists_all_config_flags to also assert that neither stdout nor
stderr contain any startup messages (e.g., "starting", "started", "launch", or
"daemon socket opened") by adding negative assertions such as
.stdout(contains("Starting").not()) and .stderr(contains("Starting").not()) (or
the test framework's equivalent) to prevent help from triggering daemon startup.
docs/weaver-design.md (1)

697-699: ⚠️ Potential issue | 🟡 Minor

Replace Oxford spelling at this locale note.

Replace localisation with localization to match repository spelling policy.

Triage: [type:spelling] [type:docstyle]

As per coding guidelines, "Use British English spelling based on the Oxford English Dictionary (en-GB-oxendict), including: -ize suffixes ..."

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

In `@docs/weaver-design.md` around lines 697 - 699, The phrase "localisation" in
the roadmap note (referenced by roadmap item "3.2.1" and the surrounding
sentence mentioning the shared augmented clap `Command`) should be changed to
the repository's preferred spelling "localization"; update that word in the
sentence and scan the same paragraph for any other occurrences of "localisation"
to make them consistent with the repository spelling policy.
crates/weaver-config/tests/configuration_precedence.rs (1)

136-139: ⚠️ Potential issue | 🟠 Major

Serialise environment mutation across tests.

Stop extending unguarded global env mutation through Harness::set_env; gate env writes behind a shared mutex-backed guard in test_utils/test_helpers and restore with RAII to prevent cross-test races.

Run this read-only check to confirm the unguarded mutation path and missing shared guard:

#!/bin/bash
set -euo pipefail

echo "Inspect env mutation sites and nearby guard usage in configuration precedence tests:"
rg -n -C3 'fn set_env|std::env::set_var|std::env::remove_var|Mutex|OnceLock|LazyLock' \
  crates/weaver-config/tests/configuration_precedence.rs

echo
echo "Locate shared test utility crates that should host env guards:"
fd -i 'test_utils|test_helpers' crates

echo
echo "Scan test code for env mutation patterns and guard constructs:"
rg -n -C2 'set_var|remove_var|Mutex|OnceLock|LazyLock' crates --type rust -g '*test*'

Expected result: env mutation sites appear in this harness without a shared guard held across mutation and restoration.
As per coding guidelines, "Environment access (env::set_var and env::remove_var) are always unsafe in Rust 2024 ... env mutations in tests MUST be wrapped in shared guards and mutexes placed in a shared test_utils or test_helpers crate. Direct environment mutation is FORBIDDEN in tests."

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

In `@crates/weaver-config/tests/configuration_precedence.rs` around lines 136 -
139, The test mutates global environment via Harness::set_env in the
given_environment_locale_override BDD step; change Harness::set_env to use a
shared mutex-backed guard from the test utilities (e.g., a guard type in
test_utils/test_helpers like EnvGuard) so every env write is serialized and
restored with RAII, update given_environment_locale_override to acquire that
guard before calling the set method (or call a new guarded API such as
Harness::set_env_guarded) and ensure the guard restores the previous value on
drop to avoid cross-test races.
docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md (3)

336-336: ⚠️ Potential issue | 🟡 Minor

Use Oxford -ize spelling for "recognizes".

Replace recognises with recognizes to match repository spelling standards.

Triage: [type:spelling]

Based on learnings, "Adhere to the repository's en-GB Oxford spelling convention in documentation files. Use -ize spellings."

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

In `@docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md` at
line 336, Replace the British spelling "recognises" with the Oxford -ize form
"recognizes" in the sentence mentioning split_config_arguments(...); update the
phrase "`split_config_arguments(...)` recognises `--locale` in both
separate-value" so it reads "`split_config_arguments(...)` recognizes `--locale`
in both separate-value" to match the repository's -ize spelling convention.

264-268: ⚠️ Potential issue | 🟡 Minor

Remove the duplicated fragment from the retrospective bullet.

Delete the repeated crates/weaver-cli/src/help.rs sentence fragment so the bullet reads as one coherent statement.

Triage: [type:grammar] [type:docstyle]

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

In `@docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md`
around lines 264 - 268, The retrospective bullet duplicates a fragment; remove
the repeated "`crates/weaver-cli/src/help.rs`" clause so the sentence reads
smoothly: keep the note that item `3.2.6` tracks adoption of `cargo orthohelp`
in CI to replace `clap_mangen` once help metadata/locales are stable, and
mention `crates/weaver-cli/build.rs` and the runtime help path without repeating
`crates/weaver-cli/src/help.rs`; update the sentence containing `3.2.6`, `cargo
orthohelp`, `clap_mangen`, `crates/weaver-cli/src/help.rs`, and
`crates/weaver-cli/build.rs` to remove the duplicated fragment.

374-374: ⚠️ Potential issue | 🟡 Minor

Use Oxford -ize spelling for "recognizes".

Replace recognises with recognizes to match repository spelling standards.

Triage: [type:spelling]

Based on learnings, "Adhere to the repository's en-GB Oxford spelling convention in documentation files. Use -ize spellings."

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

In `@docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md` at
line 374, Change the British spelling "recognises" to the repository's Oxford
-ize form "recognizes" in the sentence "Update any loader-facing constants or
metadata so the runtime recognises" within the document; locate that exact
phrase in
docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md and
update the word to "recognizes" so it matches the repo's en-GB Oxford -ize
convention.
crates/weaver-cli/src/help.rs (1)

17-31: ⚠️ Potential issue | 🟡 Minor

Add an ordering caveat to the augmented help output.

These flags render as global clap options, but runtime parsing only honours config flags that appear before the domain or structured subcommand. State that rule in after_help or long_about; otherwise weaver daemon start --log-filter debug appears supported when it is ignored.

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

In `@crates/weaver-cli/src/help.rs` around lines 17 - 31, The augmented Command in
function command() currently adds config_path_arg() and config_field_arg(...) as
global options but doesn't warn users that runtime parsing only honors config
flags placed before the domain/structured subcommand; update the Command's help
text (use command.after_help() or command.long_about()) to append a clear
one-line caveat stating that config flags must appear before the
domain/subcommand to be effective (mention examples like "weaver daemon start
--log-filter debug" being ignored if placed after), so readers of the generated
help from Config::get_doc_metadata() understand the ordering constraint.
crates/weaver-cli/src/lib.rs (1)

251-268: 🛠️ Refactor suggestion | 🟠 Major

Extract write_help_for_args into help.rs to satisfy the 400-line limit.

The file stands at 406 lines, breaching the repository's 400-line gate. Move write_help_for_args into crates/weaver-cli/src/help.rs alongside the existing command() builder, then re-export or call it from lib.rs.

As per coding guidelines, "Files must not exceed 400 lines in length".

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

In `@crates/weaver-cli/src/lib.rs` around lines 251 - 268, The function
write_help_for_args should be moved out of lib.rs into a new or existing help
module to keep lib.rs under 400 lines: create or update
crates/weaver-cli/src/help.rs, cut the write_help_for_args definition into that
file, ensure it imports std::ffi::OsString, std::io::Write and clap::error types
(or refer to help::command()), and then in lib.rs either call
help::write_help_for_args or add pub use help::write_help_for_args; also update
any use statements in lib.rs (or module declaration) so the function is
reachable and the code compiles.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/weaver-config/src/lib.rs`:
- Line 11: Update the crate-level Rustdoc bullet that currently reads "Locale
identifier for internationalisation surfaces." to use Oxford -ize spelling by
replacing "internationalisation" with "internationalization"; locate the
module-level Rustdoc comment (the top-of-file //! doc comment in lib.rs) and
change that single word so the sentence reads "Locale identifier for
internationalization surfaces."

In `@docs/developers-guide.md`:
- Around line 400-421: The sentence in the documentation paragraph describing
handle_preflight (the paragraph starting with "handle_preflight runs after argv
splitting and before configuration loading") is missing a comma after the
introductory phrase; change "At that point the CLI has enough" to "At that
point, the CLI has enough" so the clause reads correctly and improves clarity
when referencing handle_preflight and its relation to AppError::BareInvocation
and AppError::PreflightGuidance.

---

Duplicate comments:
In `@crates/weaver-cli/src/help.rs`:
- Around line 17-31: The augmented Command in function command() currently adds
config_path_arg() and config_field_arg(...) as global options but doesn't warn
users that runtime parsing only honors config flags placed before the
domain/structured subcommand; update the Command's help text (use
command.after_help() or command.long_about()) to append a clear one-line caveat
stating that config flags must appear before the domain/subcommand to be
effective (mention examples like "weaver daemon start --log-filter debug" being
ignored if placed after), so readers of the generated help from
Config::get_doc_metadata() understand the ordering constraint.

In `@crates/weaver-cli/src/lib.rs`:
- Around line 251-268: The function write_help_for_args should be moved out of
lib.rs into a new or existing help module to keep lib.rs under 400 lines: create
or update crates/weaver-cli/src/help.rs, cut the write_help_for_args definition
into that file, ensure it imports std::ffi::OsString, std::io::Write and
clap::error types (or refer to help::command()), and then in lib.rs either call
help::write_help_for_args or add pub use help::write_help_for_args; also update
any use statements in lib.rs (or module declaration) so the function is
reachable and the code compiles.

In `@crates/weaver-cli/tests/main_entry.rs`:
- Around line 146-157: The test daemon_start_help_lists_all_config_flags
currently only asserts help flags and misses verifying no daemon startup side
effects; update the assertion chain on the command created by
cargo_bin_cmd!("weaver") in function daemon_start_help_lists_all_config_flags to
also assert that neither stdout nor stderr contain any startup messages (e.g.,
"starting", "started", "launch", or "daemon socket opened") by adding negative
assertions such as .stdout(contains("Starting").not()) and
.stderr(contains("Starting").not()) (or the test framework's equivalent) to
prevent help from triggering daemon startup.

In `@crates/weaver-config/tests/configuration_precedence.rs`:
- Around line 136-139: The test mutates global environment via Harness::set_env
in the given_environment_locale_override BDD step; change Harness::set_env to
use a shared mutex-backed guard from the test utilities (e.g., a guard type in
test_utils/test_helpers like EnvGuard) so every env write is serialized and
restored with RAII, update given_environment_locale_override to acquire that
guard before calling the set method (or call a new guarded API such as
Harness::set_env_guarded) and ensure the guard restores the previous value on
drop to avoid cross-test races.

In `@docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md`:
- Line 336: Replace the British spelling "recognises" with the Oxford -ize form
"recognizes" in the sentence mentioning split_config_arguments(...); update the
phrase "`split_config_arguments(...)` recognises `--locale` in both
separate-value" so it reads "`split_config_arguments(...)` recognizes `--locale`
in both separate-value" to match the repository's -ize spelling convention.
- Around line 264-268: The retrospective bullet duplicates a fragment; remove
the repeated "`crates/weaver-cli/src/help.rs`" clause so the sentence reads
smoothly: keep the note that item `3.2.6` tracks adoption of `cargo orthohelp`
in CI to replace `clap_mangen` once help metadata/locales are stable, and
mention `crates/weaver-cli/build.rs` and the runtime help path without repeating
`crates/weaver-cli/src/help.rs`; update the sentence containing `3.2.6`, `cargo
orthohelp`, `clap_mangen`, `crates/weaver-cli/src/help.rs`, and
`crates/weaver-cli/build.rs` to remove the duplicated fragment.
- Line 374: Change the British spelling "recognises" to the repository's Oxford
-ize form "recognizes" in the sentence "Update any loader-facing constants or
metadata so the runtime recognises" within the document; locate that exact
phrase in
docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md and
update the word to "recognizes" so it matches the repo's en-GB Oxford -ize
convention.

In `@docs/weaver-design.md`:
- Around line 697-699: The phrase "localisation" in the roadmap note (referenced
by roadmap item "3.2.1" and the surrounding sentence mentioning the shared
augmented clap `Command`) should be changed to the repository's preferred
spelling "localization"; update that word in the sentence and scan the same
paragraph for any other occurrences of "localisation" to make them consistent
with the repository spelling policy.
🪄 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: 910349e1-9636-4913-8c85-64a7e25f6a74

📥 Commits

Reviewing files that changed from the base of the PR and between a6b72ad and aa68083.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • crates/weaver-cli/src/tests/unit/snapshots/weaver_cli__tests__unit__help_output__daemon_start_augmented_help.snap is excluded by !**/*.snap
  • crates/weaver-cli/src/tests/unit/snapshots/weaver_cli__tests__unit__help_output__top_level_augmented_help.snap is excluded by !**/*.snap
📒 Files selected for processing (21)
  • Makefile
  • crates/weaver-cli/Cargo.toml
  • crates/weaver-cli/build.rs
  • crates/weaver-cli/src/errors.rs
  • crates/weaver-cli/src/help.rs
  • crates/weaver-cli/src/lib.rs
  • crates/weaver-cli/src/preflight.rs
  • crates/weaver-cli/src/tests/unit.rs
  • crates/weaver-cli/src/tests/unit/help_output.rs
  • crates/weaver-cli/tests/features/weaver_cli.feature
  • crates/weaver-cli/tests/main_entry.rs
  • crates/weaver-config/Cargo.toml
  • crates/weaver-config/src/lib.rs
  • crates/weaver-config/src/locale.rs
  • crates/weaver-config/tests/configuration_precedence.rs
  • crates/weaver-config/tests/features/configuration_precedence.feature
  • docs/developers-guide.md
  • docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md
  • docs/roadmap.md
  • docs/users-guide.md
  • docs/weaver-design.md

Comment thread crates/weaver-config/src/lib.rs Outdated
Comment thread docs/developers-guide.md
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 27, 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:

## Overall Comments
- In `help.rs`, `config_field_arg` uses `Box::leak` on field names, longs, value names, and possible values each time `command()` is built; consider caching a single `Command` (e.g. via `once_cell`/`lazy_static`) or otherwise avoiding repeated leaks to keep the help builder cheap and easier to reason about over time.
- The various tests asserting on the six config flags (unit, integration, and feature tests) duplicate the same list of flag strings; centralising these into a shared helper/constant would reduce the risk of drift if the flags or placeholders change again.

## Individual Comments

### Comment 1
<location path="crates/weaver-cli/src/help.rs" line_range="46-55" />
<code_context>
+    let field_id: &'static str = Box::leak(field.name.clone().into_boxed_str());
</code_context>
<issue_to_address>
**issue (bug_risk):** Avoid unbounded `Box::leak` usage when building clap args to prevent process-lifetime leaks.

This leaks `field_id`, `long_flag`, `value_name`, and each `possible_values` element on every `command()` call. That’s acceptable for a short-lived one-shot CLI, but problematic if `command()` is reused (e.g. in a long-lived process or library). Please refactor to use a shared static structure (e.g. `once_cell`/`lazy_static` or precomputed `&'static` metadata) or adjust the design so clap can use non-`'static` lifetimes where feasible.
</issue_to_address>

### Comment 2
<location path="crates/weaver-cli/src/tests/unit/help_output.rs" line_range="56-62" />
<code_context>
+    }
+}
+
+#[test]
+fn top_level_help_lists_shared_config_flags() {
+    let (exit, stdout, stderr) = run_with_args(&["weaver", "--help"]);
+    assert_eq!(exit, ExitCode::SUCCESS);
+    assert!(stderr.is_empty(), "help output must not write to stderr");
+    assert_config_flags_present(&stdout);
+}
+
+#[test]
+fn daemon_start_help_lists_shared_config_flags() {
+    let (exit, stdout, stderr) = run_with_args(&["weaver", "daemon", "start", "--help"]);
+    assert_eq!(exit, ExitCode::SUCCESS);
</code_context>
<issue_to_address>
**suggestion (testing):** Add a unit test for `--help` combined with a config flag to validate the help-only parser path

You already verify that help and `daemon start --help` don’t load config and surface all flags. To cover the new help-command wiring when a config flag is present, consider a test like:

```rust
#[test]
fn top_level_help_with_config_flag_uses_help_command() {
    let (exit, stdout, stderr) = run_with_args(&["weaver", "--config-path", "dummy.toml", "--help"]);
    assert_eq!(exit, ExitCode::SUCCESS);
    assert!(stderr.is_empty());
    assert_config_flags_present(&stdout);
}
```

This ensures help is still rendered via the `help::command` path without invoking the config loader and that the shared flags remain in the output.

```suggestion
#[test]
fn daemon_start_help_lists_shared_config_flags() {
    let (exit, stdout, stderr) = run_with_args(&["weaver", "daemon", "start", "--help"]);
    assert_eq!(exit, ExitCode::SUCCESS);
    assert!(stderr.is_empty(), "help output must not write to stderr");
    assert_config_flags_present(&stdout);
}

#[test]
fn top_level_help_with_config_flag_uses_help_command() {
    let (exit, stdout, stderr) =
        run_with_args(&["weaver", "--config-path", "dummy.toml", "--help"]);
    assert_eq!(exit, ExitCode::SUCCESS);
    assert!(stderr.is_empty(), "help output must not write to stderr");
    assert_config_flags_present(&stdout);
}
```
</issue_to_address>

### Comment 3
<location path="crates/weaver-cli/tests/main_entry.rs" line_range="116" />
<code_context>
+    }
+}
+
+#[test]
+fn top_level_help_lists_shared_config_flags() {
+    let (exit, stdout, stderr) = run_with_args(&["weaver", "--help"]);
</code_context>
<issue_to_address>
**suggestion (testing):** Also assert that daemon start help does not write to stderr

Since the integration test already validates the listed flags, you can also assert that stderr is empty to mirror the unit tests’ guarantee that help output has no diagnostics:

```rust
let assert = command.assert().success()
    .stdout(contains("--config-path <PATH>"));
// … other stdout expectations …
assert.stderr(predicates::str::is_empty());
```

This gives an end-to-end check that `weaver daemon start --help` is a clean, non-error path for users.
</issue_to_address>

### Comment 4
<location path="docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md" line_range="84-93" />
<code_context>
+- Add `locale` to the shared configuration contract in a way that is safe to
</code_context>
<issue_to_address>
**issue (typo):** Use en-GB spelling for “localiser” to match the documented spelling constraint.

Applies to all references to the “bootstrap-localizer” work (including phrases like “bootstrap-localizer implementation”) to keep spelling consistent with existing terms such as “behaviour” and “artefacts”.

Suggested implementation:

```
- Add `locale` to the shared configuration contract in a way that is safe to
  ship now and reusable by roadmap `3.3.1`. This task does not need to complete
  the later bootstrap-localiser work, but it must not contradict it.

```

Search the rest of the repository (especially design docs, execplans, and roadmap items) for “bootstrap-localizer”, “bootstrap-localizer implementation”, and similar variants, and change them to “bootstrap-localiser …” to keep terminology consistent with existing en-GB spellings such as “behaviour” and “artefacts”.
</issue_to_address>

### Comment 5
<location path="docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md" line_range="372" />
<code_context>
+`--locale` during config-argument splitting. This includes removing the
+hard-coded five-flag assumption from `crates/weaver-cli/src/lib.rs`.
+
+### Stage C: Centralize config-help metadata and build a truthful help surface
+
+Extract the config-flag catalogue out of `crates/weaver-cli/src/lib.rs` into a
</code_context>
<issue_to_address>
**issue (typo):** Consider changing “Centralize” to the en-GB form “Centralise”.

The rest of the document uses en-GB spelling (e.g. “behaviour”, “artefacts”), and the constraints specify en-GB-oxendict. Updating this heading would keep terminology consistent with that requirement.

```suggestion
### Stage C: Centralise config-help metadata and build a truthful help surface
```
</issue_to_address>

### Comment 6
<location path="crates/weaver-cli/src/preflight.rs" line_range="44" />
<code_context>
-        .as_deref()
-        .is_none_or(|op| op.trim().is_empty());
-
-    match KnownDomain::try_parse(raw_domain) {
-        Some(domain) if operation_is_missing => preflight_result(
-            write_missing_operation_guidance(stderr, localizer, domain)
</code_context>
<issue_to_address>
**issue (review_instructions):** `emit_domain_guidance` uses a 3-branch `match`; per the guidelines this should be factored into a predicate/helper function.

This `match` has three branches (`Some` with guard, `Some(_)`, and `None`), which goes over the ">2 branches" guideline. To align with the instruction, consider extracting the classification logic into a small predicate/helper (e.g. returning an enum describing the guidance case), and then have `emit_domain_guidance` perform a simpler 2-branch (or fewer) decision based on that.

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

**Path patterns:** `**/*.rs`

**Instructions:**
Move conditionals with >2 branches into a predicate function.

</details>
</issue_to_address>

### Comment 7
<location path="docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md" line_range="79" />
<code_context>
+  take effect only when they appear before the command domain or structured
+  subcommand. Do not silently make post-domain placement work as a side effect
+  of the help change.
+- Keep the JSONL transport, daemon routing, and auto-start behaviour unchanged.
+  `--help` must still complete without daemon startup or socket access.
+- Keep `weaver-config` as the authoritative source of the shared configuration
</code_context>
<issue_to_address>
**nitpick (review_instructions):** JSONL is introduced without expansion; please define the acronym (e.g. “JSON Lines (JSONL)”) on first use.

To comply with the style guidance on acronyms, expand JSONL the first time it appears, for example: "Keep the JSON Lines (JSONL) transport, daemon routing, and auto-start behaviour unchanged."

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

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

**Instructions:**
Define uncommon acronyms on first use.

</details>
</issue_to_address>

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

Tip

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

🧩 Analysis chain

Let me inspect the current state of the relevant files before giving a verdict.


🏁 Script executed:

#!/bin/bash
echo "=== crates/weaver-cli/src/help.rs ==="
cat crates/weaver-cli/src/help.rs

echo ""
echo "=== crates/weaver-cli/src/tests/unit/help_output.rs ==="
cat crates/weaver-cli/src/tests/unit/help_output.rs

echo ""
echo "=== crates/weaver-cli/tests/main_entry.rs (last 80 lines) ==="
tail -80 crates/weaver-cli/tests/main_entry.rs

echo ""
echo "=== Check for once_cell/lazy_static in help.rs ==="
rg -n "once_cell\|lazy_static\|OnceLock\|LazyLock\|static.*Command" crates/weaver-cli/src/help.rs

echo ""
echo "=== Check Box::leak SAFETY comments ==="
rg -n -A2 -B2 "Box::leak\|SAFETY" crates/weaver-cli/src/help.rs

echo ""
echo "=== Search for 'localizer' vs 'localiser' in docs ==="
rg -rn "localizer\|localiser" docs/

echo ""
echo "=== Search for 'Centralize\|Centralise' in execplan ==="
rg -n "Centraliz\|Centralis" docs/execplans/

echo ""
echo "=== Search for JSONL acronym expansion ==="
rg -n "JSONL\|JSON Lines" docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md | head -20

echo ""
echo "=== Check for shared constant for config flags in tests ==="
rg -rn "config.path\|config_flags\|CONFIG_FLAGS\|EXPECTED_FLAGS" crates/weaver-cli/src/tests/ crates/weaver-cli/tests/

echo ""
echo "=== preflight.rs emit_domain_guidance match branches ==="
rg -n -A 15 "fn emit_domain_guidance" crates/weaver-cli/src/preflight.rs

Length of output: 10499


@leynos: Here is the full verdict on each comment after inspecting the current branch state.


Annulled requirements

Comment Reason
4 ("localizer" → "localiser") en-GB-oxendict mandates -ize endings ("localize", "localizer"). Requiring "localiser" contradicts the convention. The grep confirms the term does not appear in the docs in either form, so there is nothing to act on regardless.
5 ("Centralize" → "Centralise") Same rule: en-GB-oxendict spells this "Centralize". The grep returns no hits for either form, so the heading has already been removed or reworded.

Status of remaining comments

Comment Status Evidence
Overall — Box::leak caching ✅ Resolved help.rs declares static CONFIG_FIELD_ARGS: OnceLock<Vec<ConfigFieldArgMetadata>>. promote_static() calls Box::leak once per field inside get_or_init, and the comment states "Cache construction calls this once per field, keeping the promotion bounded even when callers build the help command repeatedly."
Overall — centralise flag strings ✅ Resolved SHARED_CONFIG_HELP_FLAGS is the single source of truth; assert_config_flags_present() in the unit tests and daemon_start_help_lists_all_config_flags in the integration tests both iterate over it.
1 — unbounded Box::leak ✅ Resolved Same evidence as the overall comment above. Box::leak is now bounded to a one-time-per-field initialisation inside the OnceLock.
2 — top_level_help_with_config_flag_uses_help_command test ✅ Resolved The test is present in help_output.rs with the correct assertions (ExitCode::SUCCESS, empty stderr, assert_config_flags_present).
3 — assert stderr empty in integration test ✅ Resolved daemon_start_help_lists_all_config_flags in main_entry.rs ends with .stderr(is_empty()).
6 — 3-branch match refactor ✅ Resolved emit_domain_guidance now calls domain_guidance() which returns Option<DomainGuidanceToEmit>; the subsequent match has exactly 2 arms (MissingOperation and UnknownDomain). The branching budget is respected without adding unnecessary complexity.
7 — JSONL acronym expansion ✅ Resolved rg finds no bare JSONL in the execplan; the term has either been expanded or reworded.

All live comments are resolved. All remaining comments from the previous review are now closed.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 27, 2026

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response. Ensure that this is validated against the current version of the codegraph.

If further refinement to address this finding would be deleterious, please supply a clear explanatory one to two paragraph markdown message I can paste into the CodeScene web ui's diagnostic suppression function so this diagnostic can be silenced.

Code Duplication

crates/weaver-cli/src/preflight.rs:

What lead to degradation?

The module contains 2 functions with similar structure: tests.known_domain_without_operation_returns_preflight_guidance,tests.unknown_domain_returns_preflight_guidance

Why does this problem occur?

Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health.

How to fix it?

A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. Read More
Once you have identified the similarities across functions, look to extract and encapsulate the concept that varies into its own function(s). These shared abstractions can then be re-used, which minimizes the amount of duplication and simplifies change.

@coderabbitai

This comment was marked as resolved.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

Add the missing blank line before the next top-level heading so the developer
guide satisfies the Markdown lint rules after the rebase.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot added Issue and removed Roadmap labels Apr 27, 2026
Make bare invocations consistently emit preflight guidance even when leading
configuration flags are present, and update the affected tests.

Move daemon execution helpers into `runner_glue` so `lib.rs` stays below the
repository file-size limit. Also align `insta` with the workspace dependency,
rerun manpage generation when `src/help.rs` changes, and refresh the roadmap
and execplan notes for the shipped locale/help architecture.
codescene-delta-analysis[bot]

This comment was marked as 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: 1

♻️ Duplicate comments (4)
crates/weaver-cli/Cargo.toml (1)

45-45: ⚠️ Potential issue | 🟡 Minor

Switch insta on Line 45 to the workspace dependency.

Replace the pinned insta = "1.39" with the workspace-managed dependency to remove version skew against the root workspace (1.41).

Patch
-insta = "1.39"
+insta = { workspace = true }

Run this read-only check to verify the mismatch before applying the patch:

#!/usr/bin/env bash
set -euo pipefail

echo "Root workspace insta entry:"
rg -n '^\s*insta\s*=' Cargo.toml -n -C1

echo
echo "weaver-cli insta entry:"
rg -n '^\s*insta\s*=' crates/weaver-cli/Cargo.toml -n -C1

As per coding guidelines, "Use explicit version ranges in Cargo.toml and keep dependencies up-to-date."

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

In `@crates/weaver-cli/Cargo.toml` at line 45, Replace the pinned insta = "1.39"
entry in the weaver-cli crate's Cargo.toml with the workspace-managed dependency
(insta = { workspace = true }) to align with the root workspace insta version
(1.41); update the dependency line in crates/weaver-cli Cargo.toml and then run
the provided read-only grep check to confirm the workspace entry is now used and
the version skew is resolved.
crates/weaver-cli/build.rs (1)

18-20: ⚠️ Potential issue | 🟠 Major

Add a rerun trigger for src/help.rs.

Track the help module explicitly. Once Line 19 opts into explicit rerun-if-changed handling, Cargo stops whole-package tracking; because Line 30 renders the man page from help::command(), edits in src/help.rs can leave the generated manual page stale.

Patch
     // Regenerate the manual page when the CLI or metadata changes.
     println!("cargo:rerun-if-changed=src/cli.rs");
+    println!("cargo:rerun-if-changed=src/help.rs");
     println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/weaver-cli/build.rs` around lines 18 - 20, Add an explicit Cargo rerun
trigger for the help module so changes to src/help.rs regenerate the man page;
in crates/weaver-cli build.rs next to the existing
println!("cargo:rerun-if-changed=src/cli.rs") and before
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION"), add a similar println
call for "cargo:rerun-if-changed=src/help.rs" to ensure edits to help::command()
cause rebuilds.
crates/weaver-cli/src/preflight.rs (1)

34-46: ⚠️ Potential issue | 🟠 Major

Remove the config-flag exemption from bare invocation.

Drop the && !split.has_config_flags() guard on Line 40. As written, weaver --config-path broken.toml skips preflight, loads configuration, and can fail on config I/O or parsing instead of emitting the bare-invocation guidance that this boundary is meant to own.

Patch
 pub(crate) fn handle_preflight<ErrWriter: Write>(
     cli: &Cli,
-    split: &ConfigArgumentSplit,
+    _split: &ConfigArgumentSplit,
     stderr: &mut ErrWriter,
     localizer: &dyn Localizer,
 ) -> Result<(), AppError> {
-    if cli.is_bare_invocation() && !split.has_config_flags() {
+    if cli.is_bare_invocation() {
         tracing::debug!("emitting bare invocation guidance");
         actionable_guidance::write_bare_invocation_guidance(stderr, localizer)
             .map_err(AppError::EmitBareHelp)?;
         PREFLIGHT_GUIDANCE_EMISSIONS.fetch_add(1, Ordering::Relaxed);
         return Err(AppError::BareInvocation);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/weaver-cli/src/preflight.rs` around lines 34 - 46, Remove the
config-flag exemption in handle_preflight so bare invocations always emit
guidance: update the function signature to accept but ignore the
ConfigArgumentSplit (rename split to _split) and change the conditional from `if
cli.is_bare_invocation() && !split.has_config_flags()` to `if
cli.is_bare_invocation() { ... }`, leaving the body that calls
actionable_guidance::write_bare_invocation_guidance, increments
PREFLIGHT_GUIDANCE_EMISSIONS, and returns AppError::BareInvocation unchanged.
crates/weaver-cli/src/lib.rs (1)

283-351: 🛠️ Refactor suggestion | 🟠 Major

Extract these daemon-dispatch helpers out of lib.rs.

Finish the decomposition here. The file still runs past the 400-line cap, and execute_daemon_command plus build_request are now the remaining bulk that belongs with the command/dispatch plumbing rather than the crate root. As per coding guidelines, "Files must not exceed 400 lines in length".

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

In `@crates/weaver-cli/src/lib.rs` around lines 283 - 351, The file exceeds the
400-line limit because daemon-dispatch helpers remain in lib.rs; move
execute_daemon_command, build_request, connect_or_start_daemon (and any small
helpers they need, e.g., is_daemon_not_running or start_and_retry_daemon if
referenced) into a new module (e.g., crate::daemon::dispatch) and re-export or
adjust visibility so callers still find execute_daemon_command and
build_request; update imports in the new file to bring in CommandInvocation,
LifecycleContext, IoStreams, ResolvedOutputFormat, OutputContext,
CommandRequest, AppError, Connection, ExitCode, read_daemon_messages,
write_error_and_fail, connect, etc., add a mod declaration in lib.rs and a pub
use if needed, and run cargo build to fix any missing visibility or use-path
errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/weaver-config/src/locale.rs`:
- Line 4: Update the module doc comment that currently reads "the wider CLI
localisation bootstrap remains future work..." to use en-GB-oxendict -ize
spelling by replacing "localisation" with "localization" in the doc string in
locale.rs (the top-level //! comment), ensuring the rest of the sentence remains
unchanged.

---

Duplicate comments:
In `@crates/weaver-cli/build.rs`:
- Around line 18-20: Add an explicit Cargo rerun trigger for the help module so
changes to src/help.rs regenerate the man page; in crates/weaver-cli build.rs
next to the existing println!("cargo:rerun-if-changed=src/cli.rs") and before
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION"), add a similar println
call for "cargo:rerun-if-changed=src/help.rs" to ensure edits to help::command()
cause rebuilds.

In `@crates/weaver-cli/Cargo.toml`:
- Line 45: Replace the pinned insta = "1.39" entry in the weaver-cli crate's
Cargo.toml with the workspace-managed dependency (insta = { workspace = true })
to align with the root workspace insta version (1.41); update the dependency
line in crates/weaver-cli Cargo.toml and then run the provided read-only grep
check to confirm the workspace entry is now used and the version skew is
resolved.

In `@crates/weaver-cli/src/lib.rs`:
- Around line 283-351: The file exceeds the 400-line limit because
daemon-dispatch helpers remain in lib.rs; move execute_daemon_command,
build_request, connect_or_start_daemon (and any small helpers they need, e.g.,
is_daemon_not_running or start_and_retry_daemon if referenced) into a new module
(e.g., crate::daemon::dispatch) and re-export or adjust visibility so callers
still find execute_daemon_command and build_request; update imports in the new
file to bring in CommandInvocation, LifecycleContext, IoStreams,
ResolvedOutputFormat, OutputContext, CommandRequest, AppError, Connection,
ExitCode, read_daemon_messages, write_error_and_fail, connect, etc., add a mod
declaration in lib.rs and a pub use if needed, and run cargo build to fix any
missing visibility or use-path errors.

In `@crates/weaver-cli/src/preflight.rs`:
- Around line 34-46: Remove the config-flag exemption in handle_preflight so
bare invocations always emit guidance: update the function signature to accept
but ignore the ConfigArgumentSplit (rename split to _split) and change the
conditional from `if cli.is_bare_invocation() && !split.has_config_flags()` to
`if cli.is_bare_invocation() { ... }`, leaving the body that calls
actionable_guidance::write_bare_invocation_guidance, increments
PREFLIGHT_GUIDANCE_EMISSIONS, and returns AppError::BareInvocation unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3f3a1c15-8225-4feb-a4dc-e45b57fbc3cb

📥 Commits

Reviewing files that changed from the base of the PR and between d3d8665 and 4506f59.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • crates/weaver-cli/src/tests/unit/snapshots/weaver_cli__tests__unit__help_output__daemon_start_augmented_help.snap is excluded by !**/*.snap
  • crates/weaver-cli/src/tests/unit/snapshots/weaver_cli__tests__unit__help_output__top_level_augmented_help.snap is excluded by !**/*.snap
📒 Files selected for processing (17)
  • Cargo.toml
  • Makefile
  • crates/weaver-cli/Cargo.toml
  • crates/weaver-cli/build.rs
  • crates/weaver-cli/src/errors.rs
  • crates/weaver-cli/src/help.rs
  • crates/weaver-cli/src/lib.rs
  • crates/weaver-cli/src/preflight.rs
  • crates/weaver-cli/src/tests/behaviour.rs
  • crates/weaver-cli/src/tests/unit/help_output.rs
  • crates/weaver-cli/tests/features/weaver_cli.feature
  • crates/weaver-cli/tests/main_entry.rs
  • crates/weaver-config/Cargo.toml
  • crates/weaver-config/src/lib.rs
  • crates/weaver-config/src/locale.rs
  • crates/weaver-config/tests/configuration_precedence.rs
  • crates/weaver-config/tests/features/configuration_precedence.feature

Comment thread crates/weaver-config/src/locale.rs Outdated
@coderabbitai coderabbitai Bot added Roadmap and removed Issue labels Apr 27, 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: 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 `@crates/weaver-cli/src/lib.rs`:
- Around line 32-40: Add the same MAINTENANCE comment above
SHARED_CONFIG_HELP_FLAGS that exists above CONFIG_CLI_FLAGS: state that these
entries must be kept in sync with the `cli_long` attributes in
`weaver-config::Config` and reference `CONFIG_CLI_FLAGS` so future editors know
to update both places; place the comment immediately above the `pub const
SHARED_CONFIG_HELP_FLAGS` declaration and mirror the wording/format used for the
existing MAINTENANCE note on `CONFIG_CLI_FLAGS`.

In `@crates/weaver-cli/tests/main_entry.rs`:
- Around line 11-12: The test currently imports SHARED_CONFIG_HELP_FLAGS which
couples the integration test to production constants; instead define a local
constant EXPECTED_SHARED_CONFIG_HELP_FLAGS with the six expected flags and use
it in place of SHARED_CONFIG_HELP_FLAGS. Remove SHARED_CONFIG_HELP_FLAGS from
the use/import line (keep DOMAIN_OPERATIONS), add const
EXPECTED_SHARED_CONFIG_HELP_FLAGS: &[&str] = &["--config-path <PATH>",
"--daemon-socket <ENDPOINT>", "--log-filter <FILTER>", "--log-format <FORMAT>",
"--capability-overrides <DIRECTIVE>", "--locale <LOCALE>"], and update all loops
and assertions that iterate over SHARED_CONFIG_HELP_FLAGS to iterate over
EXPECTED_SHARED_CONFIG_HELP_FLAGS (including the combined.contains(flag) checks
and assert.stdout(contains(*flag)) calls).

In `@docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md`:
- Line 13: Remove or rewrite the sentence "This plan must be approved before
implementation begins." from the ExecPlan (the pre-implementation approval gate)
so the document no longer contradicts its Status: COMPLETE; either delete that
line or replace it with a retrospective note explaining approval was obtained
prior to implementation, and make the same change for the duplicated content
around the retrospective section referenced in the file (the block currently
repeating the pre-implementation gate).
🪄 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: 54f023e6-d337-4db6-a423-00c05f4b469d

📥 Commits

Reviewing files that changed from the base of the PR and between 4506f59 and ce7a618.

📒 Files selected for processing (10)
  • crates/weaver-cli/Cargo.toml
  • crates/weaver-cli/build.rs
  • crates/weaver-cli/src/config.rs
  • crates/weaver-cli/src/lib.rs
  • crates/weaver-cli/src/preflight.rs
  • crates/weaver-cli/src/runner_glue.rs
  • crates/weaver-cli/src/tests/unit/bare_invocation.rs
  • crates/weaver-cli/tests/main_entry.rs
  • docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md
  • docs/roadmap.md
💤 Files with no reviewable changes (1)
  • crates/weaver-cli/src/config.rs

Comment thread crates/weaver-cli/src/lib.rs
Comment thread crates/weaver-cli/tests/main_entry.rs Outdated
Comment thread docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md Outdated
Use Oxford -ize spelling in the locale module documentation so the Rustdoc
comment matches the repository style guide.
codescene-delta-analysis[bot]

This comment was marked as outdated.

Document that the rendered config help list must stay in sync with the config
metadata and runtime stripping table.

Keep the binary integration test independent of production constants, and turn
the completed ExecPlan approval gate into retrospective wording.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 27, 2026

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

❌ Failed checks (3 errors, 5 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Testing (Overall) ❌ Error Three critical review comments remain unaddressed: production constant imported in tests instead of using test-local fixture; SHARED_CONFIG_HELP_FLAGS lacks MAINTENANCE synchronisation comment; ExecPlan document contains pre-implementation approval language despite being marked COMPLETE. Refactor tests to define local EXPECTED_SHARED_CONFIG_HELP_FLAGS constant; add MAINTENANCE doc-comment to SHARED_CONFIG_HELP_FLAGS explaining synchronisation requirements; remove or rewrite approval gate section from ExecPlan to reflect retrospectively that implementation proceeded after approval.
Module-Level Documentation ❌ Error Four new modules were introduced; three have comprehensive documentation for all public functions, but runner_glue.rs lacks documentation comments for two public functions. Add /// documentation comments to execute_daemon_command and build_request functions in runner_glue.rs, describing parameters, return types, and functionality per documented standards.
Unit Architecture ❌ Error Hidden static atomic counters mutated during nominally query-like operations without explicit API contracts, documentation, or dependency injection. Remove static counter mutations or refactor to inject an instrumentation interface as a parameter; document all intentional side-effects in function signatures and tests.
Developer Documentation ⚠️ Warning Pull request fails to address three documented review comments: ExecPlan approval gate contradicts completed status, SHARED_CONFIG_HELP_FLAGS lacks required MAINTENANCE comment, and integration tests remain coupled to production constant. Remove approval section from ExecPlan, add MAINTENANCE comment to SHARED_CONFIG_HELP_FLAGS, refactor tests to use test-local constant instead of importing production constant.
Testing (Unit) ⚠️ Warning Three new modules (help.rs, preflight.rs, runner_glue.rs) lack comprehensive unit test coverage for edge cases, error paths, and critical functions including write_help_for_args writer failures, build_request patch reading scenarios, execute_daemon_command error handling, atomic counter assertions, and Locale serialisation roundtrips. Add dedicated unit tests for write_help_for_args error handling, build_request patch reading success and failure paths, execute_daemon_command connection and error scenarios, atomic counter increments, and Locale JSON roundtrips.
Testing (Property / Proof) ⚠️ Warning PR introduces critical ordering invariant (flags before domain/subcommand) yet lacks property-based tests or bounded model checking to verify this constraint across diverse input combinations. Implement proptest-based property tests generating arbitrary flag/domain/operation combinations, verifying pre-domain flags take effect whilst post-domain flags do not. Document safety guarantees explicitly.
Observability ⚠️ Warning Runner_glue.rs lacks tracing instrumentation for daemon execution, socket connections, and retry logic; help.rs and preflight.rs define counters without logging or metric exposure. Instrument runner_glue.rs with structured tracing for socket attempts, startup requests, and failures; add debug logging to help.rs; expose HELP_RENDER_ATTEMPTS and PREFLIGHT_GUIDANCE_EMISSIONS counters as metrics.
Concurrency And State ⚠️ Warning Static atomic counters HELP_RENDER_ATTEMPTS and PREFLIGHT_GUIDANCE_EMISSIONS are incremented but never exposed, read, or validated in tests, constituting unmaintained dead code. Remove unused static counters entirely. Introduce runtime diagnostics or testing instrumentation only with explicit public exposure, read paths, and test assertions validating their values.
Testing (Compile-Time / Ui) ❓ Inconclusive Snapshot test file and insta dependency declarations cannot be verified to exist in the repository. Verify that crates/weaver-cli/src/tests/unit/help_output.rs, snapshot files, and insta/proptest dev-dependencies are actually present in the codebase.

@coderabbitai

This comment was marked as resolved.

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 `@docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md`:
- Around line 266-268: Replace the first occurrence of the acronym "CI" in the
sentence referencing roadmap item `3.2.6` (the line mentioning `cargo orthohelp`
and `crates/weaver-cli/build.rs` and `clap_mangen`) with the expanded form
"Continuous Integration (CI)"; keep subsequent uses as "CI" and ensure the
change appears where "in CI" currently reads so the document now says "in
Continuous Integration (CI)" on first use.
🪄 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: a29d423c-7bbd-4881-bb6c-906552975a47

📥 Commits

Reviewing files that changed from the base of the PR and between ce7a618 and 9739973.

📒 Files selected for processing (4)
  • crates/weaver-cli/src/lib.rs
  • crates/weaver-cli/tests/main_entry.rs
  • crates/weaver-config/src/locale.rs
  • docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md

Comment thread docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md Outdated
Define Continuous Integration on first use in the completed 3.2.1 ExecPlan so
the retrospective note follows the documentation acronym style.
codescene-delta-analysis[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot added Issue and removed Roadmap labels Apr 27, 2026
Document the runner glue APIs and add tracing around daemon connection and
auto-start paths. Remove the remaining atomic observability counters so the
runtime uses tracing for these paths.

Add focused coverage for help writer failures, request construction, locale
JSON round-trips, and the configuration-flag ordering invariant. Keep shared
help flag expectations local to tests so production constants cannot mask a
regression.
codescene-delta-analysis[bot]

This comment was marked as 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: 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 `@docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md`:
- Around line 67-117: Add three explicit, normative headings to the ExecPlan:
"Fail-fast discovery", "YAML 1.2 semantics", and "ortho-config v0.8.0 dependency
graph", and under each state the observable behaviour required (e.g.
configuration loading must fail immediately on invalid files, YAML parsing
follows YAML 1.2 semantics with any differences noted, and the ortho-config
v0.8.0 model and dependency graph that the project relies on), phrasing each as
a requirement tied to testable outcomes; ensure the wording is prescriptive,
short, and placed as top-level sections in the same document so they are
discovered by reviewers and tooling (triage: [type:docstyle]).
- Around line 153-171: Add GitHub-flavored numeric footnote citations for each
referenced document/contract in this ExecPlan by inserting [^n] markers at each
first-appearance claim (respecting first-appearance order) and then append a
numbered footnote block mapping each [^n] to the corresponding document or
contract; do this for the cited items in the checklist and the other affected
section (the block noted "Also applies to: 420-435"). Use the same numbering
convention throughout and ensure references to the code/contract mentions
(crates/weaver-cli/src/config.rs::split_config_arguments(...),
crates/weaver-cli/src/cli.rs::Cli, crates/weaver-config/src/lib.rs::Config, and
crates/weaver-cli/build.rs::help::command()) are each footnoted where they are
asserted.
🪄 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: 22fa3921-c684-43f0-a48a-898179d33ff2

📥 Commits

Reviewing files that changed from the base of the PR and between 9739973 and 3bdd21f.

📒 Files selected for processing (1)
  • docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md

Comment thread docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md Outdated
@coderabbitai coderabbitai Bot added Roadmap and removed Issue labels Apr 27, 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: 4

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

Inline comments:
In `@crates/weaver-cli/src/help.rs`:
- Around line 93-103: The code is pulling short help text via
config_field_help() instead of carrying it through the metadata path; update the
construction of ConfigFieldArgMetadata (and any other metadata uses around the
other block at 129-137) to include the short help text from the field/source of
truth and remove the switch in config_field_help(), so that
ConfigFieldArgMetadata (used by config_arg_from_metadata) contains the canonical
help string (e.g. add/rename the metadata field used for help and populate it
from the original field.help/source) and render help exclusively from that
metadata everywhere.

In `@crates/weaver-cli/src/preflight.rs`:
- Around line 29-34: Remove the now-unused '_split: &ConfigArgumentSplit'
parameter from the handle_preflight signature and all call sites (the function
is pub(crate) fn handle_preflight<ErrWriter: Write>(cli: &Cli, stderr: &mut
ErrWriter, localizer: &dyn Localizer) -> Result<(), AppError>), then collapse
any duplicated match/if branches inside handle_preflight that only differed by
the boolean has_config_flags into a single path (compute has_config_flags where
needed but do not keep separate duplicated bare-invocation cases), and update
tests to stop constructing ConfigArgumentSplit for preflight calls; keep
references to ErrWriter, Cli, Localizer, and has_config_flags to help locate the
relevant code to change.

In `@crates/weaver-config/src/locale.rs`:
- Around line 18-23: The LocaleParseError currently embeds raw input into its
Display via the #[error("invalid locale `{input}`")] format, which can leak
control characters to stderr; update the error annotation on struct
LocaleParseError to use a debug-escaped representation of the input (use
{input:?} instead of `{input}`) so invalid locale strings are escaped when
formatted, keeping the field name input unchanged.
- Around line 10-16: Add unit tests that cover BCP 47 locale extensions (e.g.
"en-US-u-ca-gregory") by parsing them into the validated Locale wrapper and
asserting round-trip equality; specifically, write tests that use
LanguageIdentifier::from_str (or langid! helper) to produce a
LanguageIdentifier, construct or parse a Locale from that string, then assert
the Locale's inner LanguageIdentifier matches and that serializing+deserializing
(serde) the Locale yields an identical value. Place tests alongside existing
locale tests and include at least one example with a "-u-*" Unicode extension to
ensure parsing and serde round-trip stability for extensions.
🪄 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: 4a2fcdf9-4997-468f-b87d-9c1ef0bb9647

📥 Commits

Reviewing files that changed from the base of the PR and between 3bdd21f and 394b870.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • Cargo.toml
  • crates/weaver-cli/Cargo.toml
  • crates/weaver-cli/src/config.rs
  • crates/weaver-cli/src/help.rs
  • crates/weaver-cli/src/preflight.rs
  • crates/weaver-cli/src/runner_glue.rs
  • crates/weaver-cli/src/tests/behaviour.rs
  • crates/weaver-cli/src/tests/unit/help_output.rs
  • crates/weaver-config/Cargo.toml
  • crates/weaver-config/src/locale.rs

Comment thread crates/weaver-cli/src/help.rs
Comment thread crates/weaver-cli/src/preflight.rs
Comment thread crates/weaver-config/src/locale.rs Outdated
Comment thread crates/weaver-config/src/locale.rs
Carry configuration help text through the help metadata path instead of
switching on field names, and remove the unused preflight split parameter.

Validate full locale tags with the ICU locale parser so Unicode extension
tags round-trip cleanly while preserving the base language identifier for
existing comparisons. Escape invalid locale input in errors with debug
formatting.

Document the ExecPlan requirements and add footnotes for the referenced
contracts so the completed plan remains auditable.
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 (1)
crates/weaver-cli/src/help.rs (1)

25-45: 🧹 Nitpick | 🔵 Trivial

Remove duplicated help-text mapping and source help from a single metadata origin.

Delete the CONFIG_FIELD_HELP lookup table and DEFAULT_CONFIG_FIELD_HELP fallback path. Drive Arg::help from one canonical metadata source so flag descriptions in --help, manpages, and config docs cannot drift when help IDs or fields change.

Also applies to: 150-155

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

In `@crates/weaver-cli/src/help.rs` around lines 25 - 45, Remove the duplicate
help-text mapping by deleting the CONFIG_FIELD_HELP array and
DEFAULT_CONFIG_FIELD_HELP constant and update any code that uses them to instead
call into the canonical metadata source when building Arg::help; specifically
replace usages that lookup keys in CONFIG_FIELD_HELP or fall back to
DEFAULT_CONFIG_FIELD_HELP with a single metadata fetch (e.g., a function or
struct method that returns the help string for a given help ID) so Arg::help is
populated from that single origin for flags, manpages, and config docs.
🤖 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/3-2-1-surface-configuration-flags-in-clap-help-output.md`:
- Around line 389-394: The doc currently uses speculative language "likely
`en-US`" for the locale default; change that sentence to state the implemented
default explicitly (e.g., "the default is `en-US`") so the field description for
`--locale` / `WEAVER_LOCALE` records the actual default used by the ExecPlan
(marked COMPLETE) rather than speculative wording.
- Around line 230-233: Replace the stale type references: change all occurrences
of unic_langid::LanguageIdentifier in the ExecPlan text to the actual shipped
wrapper type ortho_config::LanguageIdentifier (matching the developers-guide),
and update the documented default (the phrase "likely `en-US`") to the actual
shipped default value used by the codebase (use the canonical default constant
or Config/default for locale, e.g., the value returned by
ortho_config::LanguageIdentifier::default or Config::DEFAULT_LOCALE) so the
documentation exactly matches the workspace boundary and defaults.

---

Duplicate comments:
In `@crates/weaver-cli/src/help.rs`:
- Around line 25-45: Remove the duplicate help-text mapping by deleting the
CONFIG_FIELD_HELP array and DEFAULT_CONFIG_FIELD_HELP constant and update any
code that uses them to instead call into the canonical metadata source when
building Arg::help; specifically replace usages that lookup keys in
CONFIG_FIELD_HELP or fall back to DEFAULT_CONFIG_FIELD_HELP with a single
metadata fetch (e.g., a function or struct method that returns the help string
for a given help ID) so Arg::help is populated from that single origin for
flags, manpages, and config docs.
🪄 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: 090d217a-ef0e-40e5-b194-0ea00ab2a2ca

📥 Commits

Reviewing files that changed from the base of the PR and between 394b870 and ad183df.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • Cargo.toml
  • crates/weaver-cli/src/help.rs
  • crates/weaver-cli/src/lib.rs
  • crates/weaver-cli/src/preflight.rs
  • crates/weaver-cli/src/tests/unit.rs
  • crates/weaver-cli/src/tests/unit/bare_invocation.rs
  • crates/weaver-cli/src/tests/unit/help_output.rs
  • crates/weaver-config/Cargo.toml
  • crates/weaver-config/src/locale.rs
  • docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md

Comment on lines +230 to +233
- `unic_langid::LanguageIdentifier` is not serde-enabled through the current
workspace dependency surface, so a direct `Config::locale` field would not
compile. A small validated `Locale` newtype in `weaver-config` keeps the
config contract honest without adding new dependency churn.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for locale-related crate references and type names
rg -n "unic_langid|icu_locale_core|LanguageIdentifier" --type toml --type md

# Also check for the mentioned lines in the specific file
echo "---"
echo "Lines 230-233:"
sed -n '230,233p' docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md

echo "---"
echo "Lines 291-293:"
sed -n '291,293p' docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md

echo "---"
echo "Lines 389-394:"
sed -n '389,394p' docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md

Repository: leynos/weaver

Length of output: 1820


Replace stale unic_langid references with the correct type the workspace actually ships.

The ExecPlan documentation at lines 230, 255, and 292 references unic_langid::LanguageIdentifier, but the workspace manifest specifies icu_locale_core as the dependency. The developers-guide correctly uses ortho_config::LanguageIdentifier for the wrapped type. Update these three locations to match the actual shipped boundary.

Additionally, line 389 specifies the default as "likely en-US" in a document marked Status: COMPLETE. Record the actual shipped default value rather than conjecture.

Triage: [type:docstyle]

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

In `@docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md`
around lines 230 - 233, Replace the stale type references: change all
occurrences of unic_langid::LanguageIdentifier in the ExecPlan text to the
actual shipped wrapper type ortho_config::LanguageIdentifier (matching the
developers-guide), and update the documented default (the phrase "likely
`en-US`") to the actual shipped default value used by the codebase (use the
canonical default constant or Config/default for locale, e.g., the value
returned by ortho_config::LanguageIdentifier::default or Config::DEFAULT_LOCALE)
so the documentation exactly matches the workspace boundary and defaults.

Comment on lines +389 to +394
The field should:

- participate in the same layered precedence as the existing config fields;
- be surfaced as `--locale` and `WEAVER_LOCALE`;
- have a documented default, likely `en-US`; and
- stop short of wiring the localizer bootstrap or translated help selection in
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for Default impl for Locale and locale-related configuration
rg -n "impl Default for Locale|en[-_]US|pub locale" \
  crates/weaver-config/src/locale.rs \
  crates/weaver-config/src/lib.rs \
  crates/weaver-config/tests \
  2>/dev/null || echo "Pattern search complete"

Repository: leynos/weaver

Length of output: 922


🏁 Script executed:

sed -n '35,45p' crates/weaver-config/src/locale.rs

Repository: leynos/weaver

Length of output: 309


🏁 Script executed:

sed -n '25,37p' crates/weaver-config/src/locale.rs

Repository: leynos/weaver

Length of output: 350


Replace speculative language with the implemented locale default.

The documentation states the default is "likely en-US", but the implementation definitively uses en-US. Update line 393 to remove the speculative framing and record the actual default value, since the ExecPlan is marked COMPLETE.

Triage: [type:docstyle]

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

In `@docs/execplans/3-2-1-surface-configuration-flags-in-clap-help-output.md`
around lines 389 - 394, The doc currently uses speculative language "likely
`en-US`" for the locale default; change that sentence to state the implemented
default explicitly (e.g., "the default is `en-US`") so the field description for
`--locale` / `WEAVER_LOCALE` records the actual default used by the ExecPlan
(marked COMPLETE) rather than speculative wording.

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