Skip to content

Implement diagnostic notes emission plan with shared renderer (6.4.2)#167

Draft
leynos wants to merge 2 commits intomainfrom
emit-diagnostic-notes-6-4-2-xk4uxc
Draft

Implement diagnostic notes emission plan with shared renderer (6.4.2)#167
leynos wants to merge 2 commits intomainfrom
emit-diagnostic-notes-6-4-2-xk4uxc

Conversation

@leynos
Copy link
Owner

@leynos leynos commented Mar 13, 2026

Summary

Implements the diagnostic notes emission plan for roadmap 6.4.2 by delivering a shared, deterministic note renderer and per-lint wrappers, along with tests and docs updates. The ExecPlan document is now implemented and the plan is completed.

◳ Generated by DevBoxer


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

📎 Task: https://www.devboxer.com/task/de50db5f-1067-4f83-acb2-8217ac07abec

Changes

  • New ExecPlan document: docs/execplans/6-4-2-emit-diagnostic-notes.md detailing the strategy to implement diagnostic notes for decomposition guidance (Status: COMPLETED).
  • Shared diagnostic-note renderer under common/src/decomposition_advice/note.rs to render English diagnostic notes from DecompositionSuggestion data.
  • Thin per-lint wrappers in brain_type_metrics and brain_trait_metrics to delegate to the shared renderer (format_decomposition_note).
  • Updated tests to exercise the shared renderer integration across type and trait subjects:
    • common/src/decomposition_advice/note_tests.rs
    • common/src/brain_trait_metrics/diagnostic.rs (format_decomposition_note) and diagnostic_tests.rs
    • common/src/brain_type_metrics/diagnostic.rs (format_decomposition_note) and diagnostic_tests.rs
  • Behaviour and integration tests for the new note rendering:
    • common/tests/features/decomposition_diagnostic_notes.feature
    • common/tests/decomposition_diagnostic_notes_behaviour.rs
  • Documentation updates:
    • docs/brain-trust-lints-design.md: added a new subsection (Implementation decisions 6.4.2) describing the shared renderer and per-lint wrappers, cap policies, and notes format.
    • docs/roadmap.md: updated to reflect completion of 6.4.2.

Rationale and goals

  • Provide a dedicated, deterministic diagnostic-note channel that surfaces concise decomposition guidance alongside existing metrics, enabling actionable guidance for large or incohesive subjects.
  • Keep a single source of truth for rendering through a shared renderer in common, while exposing thin per-lint wrappers to Brain-Type and Brain-Trait diagnostics to preserve existing APIs.
  • Establish clear constraints, cap policies, and testing plans to guide future implementation and ensure stability.

Changes and design overview

  • Introduce a living ExecPlan for 6.4.2 covering:
    • Purpose, constraints, tolerances, risk log, and plan
    • Stage-based plan (B through I) with milestones, tests, and documentation
  • Implement a shared rendering module under common/src/decomposition_advice (note.rs) with a function similar to:
    • format_diagnostic_note(context, suggestions) -> Option
  • Per-lint wrappers:
    • brain_type_metrics::diagnostic::format_decomposition_note(diagnostic, suggestions) -> Option
    • brain_trait_metrics::diagnostic::format_decomposition_note(diagnostic, suggestions) -> Option
  • Tests and BDD plans to validate happy/unhappy/edge cases, cap handling, and delegation to the shared renderer.
  • Documentation updates to capture final note templates and cap policies, plus roadmap status updates.

Plan of work (Stage-oriented)

  • Stage B: Write failing tests that define the decomposition-note contract
  • Stage C: Implement shared note rendering in common
  • Stage D: Wire diagnostic wrappers for brain-type and brain-trait to the shared renderer
  • Stage E: Green tests and refactor while preserving existing metric-note behaviour
  • Stage F: Document decisions in docs/brain-trust-lints-design.md
  • Stage G: Mark roadmap item 6.4.2 as done after validation
  • Stage H: Run full validation (fmt, lint, tests)
  • Stage I: Finalize living sections in this document

Validation and acceptance criteria

  • The ExecPlan document exists and is scorable against the plan (gated by approval).
  • It provides clear guidance for subsequent implementation stages and signals completion of 6.4.2.
  • All planned tests and documentation updates are aligned with the final implementation and pass.

Testing plan

  • Unit tests for the shared renderer covering happy, unhappy, edge cases, and cap handling.
  • Behaviour tests (rstest-bdd) for end-to-end rendering for both type and trait subjects.
  • Ensure existing format_note() and format_help() remain unchanged when the new channel is not invoked.
  • Validate delegation from brain-type and brain-trait wrappers to the shared renderer.

Documentation impact

  • Update docs/brain-trust-lints-design.md with a new subsection: Implementation decisions (6.4.2).
  • Update docs/roadmap.md to reflect completion only after all gates pass.
  • The ExecPlan itself is a living document and will be updated as work progresses and decisions evolve.

Risks and mitigations

  • Wording and cap policy stability: keep concise, template-driven output with deterministic ordering.
  • Potential scope creep: adhere strictly to 6.4.1 clustering results and reuse of existing data models.
  • Public API stability: additive changes only; avoid breaking changes to existing diagnostics.

Validation and acceptance criteria (detailed)

  • The ExecPlan document exists and is scorable against the plan.
  • The shared renderer and per-lint wrappers are wired and exercised by unit and behaviour tests.
  • Documentation and roadmap reflect the implemented state of 6.4.2.

Next steps after approval

  • No further actions required beyond ongoing maintenance of the living ExecPlan as decisions evolve.

◳ Generated by DevBoxer

📎 Task: https://www.devboxer.com/task/2a2e8239-cbad-4ff0-acf0-ae6e70ed8143

…4.2)

Add comprehensive ExecPlan document for roadmap item 6.4.2 that outlines the purpose, constraints, tolerances, risks, progress stages, design decisions, and implementation plan for emitting decomposition diagnostic notes in brain-trust lints. This living document details the approach to rendering concise developer-facing diagnostic notes, cap policies, test plans, integration strategies, and retrospective tracking to guide the implementation and validation stages.

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

sourcery-ai bot commented Mar 13, 2026

Reviewer's Guide

Adds a new living ExecPlan document for roadmap item 6.4.2 that specifies how to implement and validate decomposition diagnostic notes for brain-trust lints, including constraints, staged work plan, testing and documentation strategy, risk management, and acceptance criteria, without yet changing any code or behavior.

Sequence diagram for formatting decomposition diagnostic notes (6.4.2)

sequenceDiagram
    actor Developer
    participant BrainTypeLintDriver
    participant BrainTypeDecompositionWrapper
    participant DecompositionNoteRenderer

    Developer->>BrainTypeLintDriver: run_brain_type_analysis()
    BrainTypeLintDriver->>BrainTypeLintDriver: compute DecompositionSuggestion[]
    BrainTypeLintDriver->>BrainTypeDecompositionWrapper: format_decomposition_note(diagnostic, suggestions)

    BrainTypeDecompositionWrapper->>BrainTypeDecompositionWrapper: build DecompositionContext from diagnostic
    BrainTypeDecompositionWrapper->>DecompositionNoteRenderer: format_diagnostic_note(context, suggestions)

    alt suggestions is empty
        DecompositionNoteRenderer-->>BrainTypeDecompositionWrapper: None
    else suggestions present
        DecompositionNoteRenderer->>DecompositionNoteRenderer: apply caps and ordering
        DecompositionNoteRenderer-->>BrainTypeDecompositionWrapper: Some(note_text)
    end

    BrainTypeDecompositionWrapper-->>BrainTypeLintDriver: Option<String>
    BrainTypeLintDriver->>BrainTypeLintDriver: attach note to diagnostic output
    BrainTypeLintDriver-->>Developer: diagnostics with optional decomposition note
Loading

Class diagram for planned decomposition diagnostic note rendering (6.4.2)

classDiagram
    class DecompositionContext {
    }

    class DecompositionSuggestion {
    }

    class DecompositionNoteRenderer {
        +format_diagnostic_note(context: DecompositionContext, suggestions: DecompositionSuggestion[]) Option~String~
        -render_suggestion_line(label: String, extraction_kind: String, method_names: String[]) String
        -apply_method_caps(method_names: String[]) String
        -apply_suggestion_caps(lines: String[]) String
    }

    class BrainTypeDiagnostic {
    }

    class BrainTraitDiagnostic {
    }

    class BrainTypeDecompositionWrapper {
        +format_decomposition_note(diagnostic: BrainTypeDiagnostic, suggestions: DecompositionSuggestion[]) Option~String~
    }

    class BrainTraitDecompositionWrapper {
        +format_decomposition_note(diagnostic: BrainTraitDiagnostic, suggestions: DecompositionSuggestion[]) Option~String~
    }

    DecompositionNoteRenderer --> DecompositionContext : uses
    DecompositionNoteRenderer --> DecompositionSuggestion : uses

    BrainTypeDecompositionWrapper --> BrainTypeDiagnostic : uses
    BrainTraitDecompositionWrapper --> BrainTraitDiagnostic : uses

    BrainTypeDecompositionWrapper --> DecompositionNoteRenderer : delegates
    BrainTraitDecompositionWrapper --> DecompositionNoteRenderer : delegates

    DecompositionSuggestion --> DecompositionContext : contextual_data
Loading

File-Level Changes

Change Details Files
Introduce a detailed execution plan for emitting decomposition diagnostic notes for brain-trust lints.
  • Create a living ExecPlan document describing purpose, constraints, tolerances, risks, progress tracking, and decision log for roadmap item 6.4.2.
  • Define the proposed shared renderer API in the common decomposition_advice module and its cap/wording policy for diagnostic notes.
  • Lay out a staged implementation plan (tests-first, renderer, wrappers, refactor), test strategy (unit + rstest-bdd behaviour), and documentation/roadmap update steps plus validation and acceptance criteria.
docs/execplans/6-4-2-emit-diagnostic-notes.md

Tips and commands

Interacting with Sourcery

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

Customizing Your Experience

Access your dashboard to:

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

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 772265ba-94a0-432d-bf15-574e0dc8a378

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch emit-diagnostic-notes-6-4-2-xk4uxc
📝 Coding Plan
  • Generate coding plan for human review comments

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

codescene-delta-analysis[bot]

This comment was marked as outdated.

…tion diagnostic notes

- Implemented `format_diagnostic_note` to render decomposition suggestions as concise multi-line notes
- Added thin wrappers in `brain_type_metrics` and `brain_trait_metrics` to expose this renderer
- Created new module `decomposition_advice::note` for diagnostic note rendering logic with hard caps on suggestions and method counts
- Added extensive unit and BDD tests for the new rendering behavior
- Updated documentation and examples to illustrate emitted notes format
- Marked roadmap item 6.4.2 as completed

This enables emitting focused decomposition advice as separate diagnostic notes, improving clarity and consistency across brain-type and brain-trait diagnostics.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos leynos changed the title Emit diagnostic notes for brain-trust decomposition (6.4.2) Implement diagnostic notes emission plan with shared renderer (6.4.2) Mar 14, 2026
Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Gates Failed
Enforce advisory code health rules (1 file with Code Duplication)

Gates Passed
5 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Enforce advisory code health rules Violations Code Health Impact
note_tests.rs 1 advisory rule 9.39 Suppress

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

Comment on lines +222 to +282
fn format_diagnostic_note_caps_methods_per_suggestion() {
let context = DecompositionContext::new("Reporter", SubjectKind::Type);
let methods = vec![
profile(MethodInput {
name: "report_alpha",
fields: &["report"],
signature_types: &[],
local_types: &[],
domains: &[],
}),
profile(MethodInput {
name: "report_beta",
fields: &["report"],
signature_types: &[],
local_types: &[],
domains: &[],
}),
profile(MethodInput {
name: "report_delta",
fields: &["report"],
signature_types: &[],
local_types: &[],
domains: &[],
}),
profile(MethodInput {
name: "report_epsilon",
fields: &["report"],
signature_types: &[],
local_types: &[],
domains: &[],
}),
profile(MethodInput {
name: "report_gamma",
fields: &["report"],
signature_types: &[],
local_types: &[],
domains: &[],
}),
profile(MethodInput {
name: "io_alpha",
fields: &[],
signature_types: &[],
local_types: &[],
domains: &["std::io"],
}),
profile(MethodInput {
name: "io_beta",
fields: &[],
signature_types: &[],
local_types: &[],
domains: &["std::io"],
}),
];
let suggestions = suggest_decomposition(&context, &methods);

let rendered = format_diagnostic_note(&context, &suggestions).unwrap_or_default();

assert!(rendered.contains(
"- [report] helper struct for `report_alpha`, `report_beta`, `report_delta`, +2 more methods"
));
}

Choose a reason for hiding this comment

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

❌ New issue: Code Duplication
The module contains 2 functions with similar structure: format_diagnostic_note_caps_methods_per_suggestion,format_diagnostic_note_caps_rendered_suggestions

Suppress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant