Skip to content

ci: Fail the Blueprint check above 980 distinct templates - #688

Merged
edwardtfn merged 1 commit into
devfrom
ci/blueprint-distinct-template-limit
Nov 6, 2026
Merged

edwardtfn merged 1 commit into
devfrom
ci/blueprint-distinct-template-limit

Conversation

@panel-easy-assistant

@panel-easy-assistant panel-easy-assistant Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Keeps the Blueprint safely below the size of Spook's template cache, so a future change can't silently bring back the Home Assistant stalls from #636.

Details:

  • Spook caches the analysis of up to 1,024 distinct templates, shared with the templates of all other automations. Above it, every inspection re-parses every template of every panel. The Blueprint is at 960 distinct templates today.
  • blueprint_metrics.py gets --max-distinct N: above N distinct templates it prints an error and exits with 1, after writing the report to the job summary.
  • With --base, it also warns when a pull request increases the number of distinct templates, so the trend is visible before the limit is reached.
  • validate_blueprint.yml passes --max-distinct 980 (44 below the cache size). Raising it means editing the workflow, which keeps it a deliberate decision. It can be lowered as the Blueprint shrinks.
  • The step still only runs when the Blueprint or its CI files change.

Related to #636

Summary by Sourcery

Protect Blueprint validation from exceeding Spook’s template cache by adding a deliberate distinct-template limit and pull-request growth warnings.

Enhancements:

  • Enforce a 980 distinct-template limit for Blueprint validation while preserving report generation and surfacing growth relative to the base Blueprint.

CI:

  • Update Blueprint validation to fail when distinct templates exceed the configured safety margin below Spook’s 1,024-template cache.

Spook caches the analysis of up to 1,024 distinct templates, shared with all other automations; above it, every inspection re-parses every template of every panel (issue #636). The Blueprint metrics step now fails when the Blueprint has more than 980 distinct templates, and warns when a pull request increases their number. The limit lives in validate_blueprint.yml, so raising it is a visible decision.

Related to #636
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Sorry @panel-easy-assistant[bot], you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 22 hours and 29 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR adds a configurable distinct-template ceiling to Blueprint metrics, reports growth against the base revision, and configures CI to fail above 980 templates while preserving the generated metrics report and existing change-based workflow gating.

Sequence diagram for Blueprint template limit validation

sequenceDiagram
    participant CI as GitHub Actions
    participant Metrics as blueprint_metrics.py
    participant Summary as Job Summary

    CI->>Metrics: Run with --base and --max-distinct 980
    Metrics->>Metrics: Calculate current and base metrics
    Metrics->>Summary: Write metrics report
    alt Distinct templates grow
        Metrics-->>CI: Emit GitHub Actions warning
    end
    alt Distinct templates > 980
        Metrics-->>CI: Emit GitHub Actions error
        Metrics-->>CI: Exit 1
    else Limit not exceeded
        Metrics-->>CI: Exit 0
    end
Loading

Flow diagram for the Blueprint template ceiling

flowchart TD
    A[Blueprint or CI files changed] --> B[Run Blueprint metrics]
    B --> C[Compare distinct templates with base]
    C --> D[Write metrics report to job summary]
    D --> E{Distinct templates above 980?}
    E -->|No| F[CI step passes]
    E -->|Yes| G[Emit error and fail CI]
    G --> H[Reduce templates or deliberately raise limit]
Loading

File-Level Changes

Change Details Files
Add an optional hard limit for distinct Blueprint templates while preserving report generation and existing informational metrics.
  • Introduce the --max-distinct CLI option, disabled by default.
  • Emit a GitHub Actions error and return exit code 1 only when the configured limit is exceeded.
  • Keep the metrics report and job summary generation before the failure path.
  • Warn when pull-request metrics show growth in distinct templates relative to the base Blueprint.
.github/scripts/blueprint_metrics.py
Enforce a deliberate 980-template guardrail in the Blueprint validation workflow.
  • Pass --max-distinct 980 to the metrics command.
  • Document that the limit maintains margin below Spook's 1,024-entry cache and must be deliberately raised.
  • Retain the existing conditional execution when Blueprint or CI files change.
.github/workflows/validate_blueprint.yml

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

@edwardtfn
edwardtfn merged commit e8ea96b into dev Nov 6, 2026
60 checks passed
@edwardtfn
edwardtfn deleted the ci/blueprint-distinct-template-limit branch November 6, 2026 12:38
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